Is it possible to replace the {!...} template tokens with corresponding values after the script has been parsed? Right now only the template tokens manually entered in my script are replaced. I am trying to retrieve values more dynamically using arrays, generating the tokens during execution:
var statusNameNmbr = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13"]; var fields = [ ["bbs", "box", "email", "housenet", "jira", "letter", "final"] ]; var s1 = "{!web01_bbs}"; var s2 = new String("{" + '\u0021' + "web" + statusNameNmbr[0] + "_" + fields[0][0] + "}"); rbv_api.log("debug", "String #1: " + s1 + ", string #2: " + s2);
This logs "String #1: true, string #2: {!web01_bbs}", but as you may understand, I'd rather get the corresponding value (true / false for this checkbox).
I suggest of using "rbv_api.getFieldValue(objName, objId, fieldName)" instead and remove the {!} of your s2 and assign s2 to the "fieldName", here is the revised code.
var statusNameNmbr = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13"]; var fields = [ ["bbs", "box", "email", "housenet", "jira", "letter", "final"] ]; var s1 = "{!web01_bbs}"; var s2 = "web" + statusNameNmbr[0] + "_" + fields[0][0]; var myField = rbv_api.getFieldValue("product1", {!id}, s2); rbv_api.println(myField);
Hope this helps.
Regards,
Orchid
It helps, but I actually forgot to mention that I was trying to achieve something like "{!" + fields[0][1] + "[tag:before]}"; . The reason I was trying to do it like that was because I wanted to retrieve the value when evaluating it, not before the evaluation. I wanted to expand the fields array up to 90 fields; retrieving 180 field values (current value and [tag:before] value) was a bit too much.
I see, in that case just add "#before" to s2 (s2+"#before"), still make use of rbv_api.getFieldValue();
var statusNameNmbr = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13"]; var fields = [ ["bbs", "box", "email", "housenet", "jira", "letter", "final"] ]; var s1 = "{!web01_bbs}"; var s2 = "web" + statusNameNmbr[0] + "_" + fields[0][0]; var myField = rbv_api.getFieldValue("product1", {!id}, s2+"#before"); rbv_api.println(myField); return "BEFORE: "+myField + "NEW: "+{!web01_bbs};
Thanks a lot! Didn't know that was possible because I thought rbv_api.getFieldValue() retrieves values stored in the database.
Yes you can use that. Another tips, you can use another "#..." suffix too, and can be use in the query.
rbv_api.getFieldValue("product1", {!id}, "fieldName#id"); rbv_api.getFieldValue("product1", {!id}, "fieldName#code"); rbv_api.getFieldValue("product1", {!id}, "fieldName#value"); rbv_api.selectValue("SELECT fieldName#code FROM product1 WHERE id={!id}");
Hope this helps.
Regards,
Orchid
Omg that is awesome:
rbv_api.getFieldValue("product1", {!id}, "fieldName#id");
rbv_api.getFieldValue("product1", {!id}, "fieldName#code");
rbv_api.getFieldValue("product1", {!id}, "fieldName#value");
rbv_api.selectValue("SELECT fieldName#code FROM product1 WHERE id={!id}");
I didn't know it was possible and I've spent 3 years using rbv_api.getCodeById / rbv_api.getIdByCode for no reason!
Thank you very much, I will definitely use these.
Kind regards,
Romain.
Cool, good to know!
[mention:8358709d87ea4f06a7b6a0a79b0c6e01:e9ed411860ed4f2ba0265705b8793d05] didn't you use {!fieldName#suffix} before?
Hello,
Yes I did, but not in a getFieldValue or selectQuery call, I didn't know you could asked to be retrieved the code directely.
For instance, to retrieve a status code from a "distant record" (which I can't access using {!...} tokens), I would do:
var idStatus = rbv_api.getFieldValue('objName', recordId, 'status');
var codeStatus = rbv_api.getCodeById('objName', 'status', idStatus);
Orchid seems to be saying that you can do this instead:
var codeStatus = rbv_api.getFieldValue('objName', recordId, 'status#code');
Kind regards,
Romain.