Skip to main content
Question

Business Rule XML message parameters

  • November 13, 2020
  • 6 replies
  • 465 views

Forum|alt.badge.img+9
  • Sidekick (Customer)
  • 63 replies

I have a business rule on task_attachment table, but in my output XML, I need the request_id of the request that the associated task is attached to.  It seems that I can only access fields from the task_attachment table as parameters in my output XML.  I understand I can include a select XML query in my output XML to lookup other values.  Can someone please post an example of how to do this?

 

Thanks in advance

6 replies

AdrianEgley
Hero (Customer)
Forum|alt.badge.img+14
  • Hero (Customer)
  • 170 replies
  • November 13, 2020

Hi @MartinF,

I’d go down the xpath XML here.

Not sure what your output would be, but doing a hierarchy select using the task_id to obtain the request_id would do it.

An example below. Using the task_id the output would then create an event on request_event. In theory you could do the select straight from the Task table.

 

Hope this helps


Ady

<perform_batch>

    <hierarchy_select result_name="select_task_attachment01" max_rows='1'>

      <attrs>

        <attr>task_attachment.task_id</attr>

        <attr>task.request_id</attr>

      </attrs>

      <primary_table>task_attachment</primary_table>

      <from>

        <table>task_attachment</table>

        <table>task</table>

      </from>

      <where>

        <join_constraint>

          <constraint>

            <left_operand>task_attachment.task_id</left_operand>

            <operator>eq</operator>

            <right_operand>task.task_id</right_operand>

          </constraint>

        </join_constraint>

            <data_constraint>

          <constraint>

            <left_operand>task_attachment.task_id</left_operand>

            <operator>eq</operator>

            <right_operand>@task_id</right_operand>

          </constraint>

        </data_constraint>

      </where>

    </hierarchy_select>

 <update_request_event>

  <request_event>

    <request_id xpath_node="//task_attachment_hierarchy_select_result[@result_name='select_task_attachment01']/task_attachment/task/request_id"/>

    <event_type>ADD EVENT TYPE</event_type>

    <insert_update />

  </request_event>

</update_request_event>

  </perform_batch>


Forum|alt.badge.img+8
  • Hero
  • 30 replies
  • November 13, 2020

With the existing parent join from task_attachment to task (metadata), I believe the expression would work too, and less strenuous than the hierarchy select.

try this: 

<update_request_event>
  <request_event>
    <request_id>@expression[task.request_id]</request_id>
    <event_type>ADD EVENT TYPE</event_type>
    <insert_update />
  </request_event>
</update_request_event>

 


Forum|alt.badge.img+9
  • Author
  • Sidekick (Customer)
  • 63 replies
  • November 16, 2020

Hi @AdrianEgley,

 

Thanks for your prompt response. I tried your XML code and it indeed worked a treat!

 

Hi @Rwjgoedhart,

 

Thanks also for your reply! ...i have a question however: usually the parameters would be passed in like this » @task_id -so how does it resolve the ‘@expression[task.request_id]’  how does this expression know which task it is looking at?


AdrianEgley
Hero (Customer)
Forum|alt.badge.img+14
  • Hero (Customer)
  • 170 replies
  • November 16, 2020

@MartinF That’s great.

 

I’m also interested to try the way @Rwjgoedhart mentioned, if that works it maybe a few Business Rules i’ll look to update too.

 

Ady


Forum|alt.badge.img+8
  • Hero
  • 30 replies
  • November 16, 2020

in my experience, the expression in XML seems to be able to grab data that is defined in Joins in Metadata. we use this very successfully on various XML Rules today.

 

What the exact function behind it is… no idea.  I don’t remember how/where I learned the trick, and unfortunately, the Documentation is of not much help.

 

It has worked very well for us in the past though, both in Workflow scripting and Business rules, it seems to associate to the right records through the joins.

-Rudy


Forum|alt.badge.img+9
  • Author
  • Sidekick (Customer)
  • 63 replies
  • November 18, 2020

@Rwjgoedhart@AdrianEgley 

 

Just tested Rudy’s implementation and it works great too, ill be going with that one as its much simpler. Adrians solution was also very helpful as it has helped explain a bit more about how these things work.

 

Thanks again guys.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings