Hello everyone,
I'm trying to retrieve the "Name" property of my BPA enumeration:
Indeed, I can retrieve the ID using "execution.getVariable('') but what I'm interested in is the "Name" property.
Do you have any ideas?
Thanks in advance
Hello everyone,
I'm trying to retrieve the "Name" property of my BPA enumeration:
Indeed, I can retrieve the ID using "execution.getVariable('') but what I'm interested in is the "Name" property.
Do you have any ideas?
Thanks in advance
Only the id of the selected user task enumeration is readily available in the execution. Your easiest option is to introduce a duplicate json to execution that holds the enum in user form.
Script task 1:
var json = '{"enum1"::{"id": "DB_TEST1", "name": "Test1"}, {"id": "DB_TEST2", "name": "Test2"}]}';
execution.setVariable('json', JSON.parse(json));
Script task 2:
var jsonObj = execution.getVariable("json");
var sl = String(selectById(jsonObj, execution.getVariable('enum1')));
execution.setVariable('selected', sl);
function selectById(json, id) {
for (var i = 0; i < json.enum1.length; i++) {
if (json.enum11i].id == id) {
return String(json.enum11i].name);
}
}
}
Be sure to place script task 1 after the last user task.
Another option is to add the enum name resolution by id logic as a projection function and call it via an API task where necessary.
Hi
This solution works perfectly!
I hadn't thought of it at all.
Thank you very much.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.