Referencing process element properties in Script tasks

I know that we can use Get to read process parameters in C# scripts but I don't know how to use this method to read process elements' properties, like for example Created record ID. So far what I'm doing is making a new process parameter and setting its value with Formula block. Is there a better way?

Like 0

Like

2 comments

Dear Carlos,

You can access the process elements parameters in following ways. Lets say I have a ReadData element before my ScriptTask and I want to obtain the CaseId from it in my ScriptTask. First, I click "Advanced mode" (tree dots in the right top corner of right panel):

 

There you can find the Code of the element, so to address it with. Also, in the parameters tab you can see all available parameters of the element. In my example this is ReadDataUserTask1.

Here I can obtain the collection of entities from ReadData and set them to parameter, if needed:

EntityCollection entities = Get<EntityCollection>("ReadDataUserTask1.ResultEntityCollection");
Set("Param1", entities);

The other approach is to access properties though the dot, like any other properties retrieval:

var parameter = Get<Guid>(ReadDataUserTask1.CaseId);

Also, there is still working approach with read data element and setting value to the process parameter through formula element you have mentioned.

Hope you find it helpful,

Anastasia Botezat

 

Anastasia Botezat,

Thank you very much.

Show all comments