Jump to content

Recommended Posts

Posted

Hello,

My first time trying to pass more than one parameter to a script.

My research (potentially flawed) has led me to believe that one of the most robust ways of passing multiple parameters was to use JSON. I have copied JSON code from the internet and modified the code to try and work with my data to accomplish my task. I've tried my best, but I need help.

This is the JSON I have in the "Optional Script Parameter" dialog window:

JSONSetElement ( "" ;

["name"; item_feature_location::item_feature_location_name; JSONString ];

["status_type"; item_feature_location__status_portal__status_type::status_type_name; JSONString ]

)

When I copy and paste the above code into the data viewer, it does give me the first parameter value, but it does not give me the second parameter value.

What Does work:

First parameter field = item_feature_location::item_feature_location_name

What Does not work:

Second parameter field = item_feature_location__status_portal__status_type::status_type_name

What I Notice

The only thing I notice that is different between the two parameters is that the second one is from a related table.

Attaching screenshots of:

  • Optional Script Parameter
  • Script Variable of Parameters (Script)
  • Data Viewer Result

Any help is appreciated.

 

optional_script_parameter.png

script_variable_of_parameters.png

data_viewer_result.png

Posted

AFAICT the problem is not with constructing the JSON but with accessing the related value. You can verify this by evaluating only:

item_feature_location__status_portal__status_type::status_type_name

in the Data Viewer, using the same context. I believe it will return an empty string.


Keep in mind that when referring to a related field, the calculation will retrieve data from the first related record, in the sort order of the relationship.

 

Posted
7 hours ago, comment said:

AFAICT the problem is not with constructing the JSON but with accessing the related value. You can verify this by evaluating only:

item_feature_location__status_portal__status_type::status_type_name

in the Data Viewer, using the same context. I believe it will return an empty string.

When I evaluate that related field, it is successful: see screenshot.

 

Any other ideas?

evaluation result.png

Posted
15 minutes ago, dmontano said:

Any other ideas?

Not really. Your formula for constructing the JSON is correct and if the referenced field contains the text "Active" you should be getting the result you expect.

Is it possible that the two tests were performed from different records?

 

Posted
6 minutes ago, comment said:

Is it possible that the two tests were performed from different records?

Bingo. That must be it — because now it works.

Thank you very much!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.