Convert BR script into Custom Flow Action

Anderson_R
Tera Contributor

I'm trying to convert the following BR into a custom flow action with a script step. However, I'm having difficulty putting it together. Any help with the input variables, script, and output variables would be greatly appreciated. 

The business rule I'm trying to convert: 

(function executeRule(current, previous /*null when async*/) {
	// Call the script include
	new global.u_AttachmentUtils().copyAllAttachmentsToMe(current.parent.sys_class_name.toString(), current.getValue('parent'), current);
})(current, previous);


What I currently have in my flow action, but isn't working: 

Anderson_R_0-1713898136120.png

Any help is greatly appreciated! 

1 ACCEPTED SOLUTION

I have created a sample action

 

Action inputs

Karunakaran_0-1714035930728.png

Script step:

Karunakaran_1-1714035998778.png

 

I tested it with some random incidents. it worked.

Hope this helps.

 

Thank you.

 

View solution in original post

7 REPLIES 7

Karunakaran
Mega Guru

Hi @Anderson_R ,

 

When looking at the business rule, you have 3 parameters.

 

the 3 parameters are derived from current object. When the input is given to the action step, you need to make sure that it is the same object.

 

For more details about how to populate the input and generate output, please refer this link.

 

and this link as well 

 

And let me know, if you need more assistance.

 

Thank you.

 

Regards,

Karunakaran.

 

Hi Karunakaran, 
Thanks for the reply. Yes, the parameters are derived from the current object. So with one of them being current.parent, is this how the input would be configured for it?

Anderson_R_0-1713900858462.png

Considering: 

Anderson_R_2-1713900946899.png

 

 

yes, here you can define the type of inputs as per the parameters in the method you have.

 

In the previous step for the action, you need to make sure the inputs are given correctly from the data panel.

 

Please let me know, if this is confusing.

I currently have the parent field defined as a reference name. Does this look correct? I don't see a way to ensure it's retrieving the parent from the current record. 

Anderson_R_0-1713904694354.png

Then for the second parameter, it's not found directly on the current record. I would have to dot walk to it from the current record. As the BR uses current.parent.sys_class_name. How do I create an input for a field that you need to dot walk to?