Get columns read in "Read data" step

Let's say I read one object using Read data step and I choose to only read columns First name and Last name. How do I reference that data in Script task? I know I can copy those strings from step parameters to process parameters using Formula step but maybe there is a better way.

Like 0

Like

15 comments

Dear Carlos,

For the [Script-task] elements and methods that have the [For an interpreted process] checkbox selected, the wrapper class is generated that contains the initialization and declaration of methods. This wrapper enables you to access the process values. 

The Get method returns the value of an item or process.

Method signature:

Get<T>(string path)

where:

  • T — parameter value type.
  • path — a string that specifies the path to a parameter or property. The path is built according to these rules:
  1. “parameter name”
  2. “property name”
  3. “element name.parameter name”
  4. “element name.property name”

Oliver

Oliver,

I don't see a parameter First name though. The only related parameter that I see is Columns to read.

Carlos Zaldivar Batista,

You don't need any parameters and select any specific columns to read in the element Read Data, simply use “element name.property name” to get the field value in the Script task.

Oliver

Oleh Chudiiovych,

Ok, so I have a step with code ReadSomeData and I try to read the columns of returned object like this:

Get&lt;Entity&gt;("ReadSomeData.ResultEntity").GetTypedColumnValue&lt;string&gt;("UsrFirstName")

I get NullReferenceException though because the Get method returned null.

Try read data from all columns. Also possible for your query (filter) no records? Do it work if you remove the filter

Grigoriy,

I read data from all columns and the query returns records.

Dear Carlos,

As far as we can see from your method you are trying to read values from the "UsrFirstName" column and we don't know what data is stored there and what are you trying to read. Please re-check all your columns and also try Grigoriy's suggestion about filters.

Oscar

Ok, so I created a new trial environment with default test data and in that environment I created a process:

 

The Read data step looks like this:

I set up the step name too:

And that is my Script task code:

Name is a process parameter that is shown in the auto-generated screen. That's what the screen shows after running the process:

There are no filters in the read data step and the data is there. What should I change to make the script task work?

Hi by default read data have code "ReadDataUserTask1".

Try this:

var entity = Get<Entity>("ReadDataUserTask1.ResultEntity"); 

 

See read data advanced mode for get elenent code (

In the advanced mode, the element setup area contains additional parameters and connections with system records

To access the advanced mode, click the btn_advanced_mode.png button in the element setup area and select the [Advanced mode] menu command

)

Sory. For interpretable processes, you can only directly work with the methods and parameters of the elements through the formula.

In autogenerate page set page item via formula like:

[#Read data 1.First item of resulting collection.First name#] 

Grigoriy,

Thank you. And is it possible to use this formula in a script tasks?

Yes

1. Create a process parameter of type String - TestParam.

2. In the parameter value specify [#Read data 1.First item of the resulting collectionFirst name#].

3. In the Task-script element, work with the parameter.

     var contactFullName = Get<string> ("TestParam");

Grigoriy,

Ok, thank you.

Does anyone know if this is still the case? i.e. that it's necessary to save each individual field to a parameter in order to access them inside a Script Task element of a Business Process? It seems like it really should be simpler to access data on any of the fields!

 

I am aware of being able to query the entity directly within the Script Task, but I'd like to keep as much of the business logic in easy-to-read BP steps as possible, including reading data.

Dear Harvey,

 

Yes, the logic remains the same. There is still to call for read data element through the script task without the intermediate process parameters or settings. This logic will be review by our developers, it is confirmed by our R&D but we do not know when it will be done.

 

Regards,

Dean

 

Show all comments