Need to populate one variable value based on another

Rekha20
Tera Contributor

Hi All,

 

I have form:

Rekha20_0-1708191021503.png

 

where I need to populate "Org Number" and "Sub Account" based on SIU Fund variable.

 

"Org Number" and "Sub Account" referring to same table but having simple referring qualifier: 

 

"Org Number" where Type = Organization

"Sub Account" where Type = Account

 

So requirement is:

  • SIU Fund variable value is "A", Org Number" should populate as 30553, sub account should populate as 5897
  • SIU Fund variable value is "B", Org Number should populate as 30564, sub account should populate as 5897
  • SIU Fund variable value is "C", Org Number should populate as 30122, sub account should populate as 5897
  • SIU Fund variable value is "D",
    • There should only be two value available to select for Org Number variable as below
    •  03790, sub account 5897
    • 03828, sub account 5897

Challenge I am facing is how to make it dynamic for 

  • SIU Fund variable value is "D",?

Any help would be appreciated.

 

Thanks,

8 REPLIES 8

Hi @Rekha20 ,

 

You are trying to set the Filed values with Jason which will not work for Reference field. Can you try creating 2 different functions for "Org Number" and "Sub Account" and try passing sys id through array 

 

for example inside Org Number function

 

getOrgAndSubAccountValues: function(siuValue) {
        var orgAndSubAccountValues =["c374861c1b4ba5108e9987f5624bcbb9", "0b74861c1b4ba5108e9987f5624bcbc1"];
 
  
        if (siuValue === "D") {
                        return "sys_idIN" + orgAndSubAccountValues.toString();
}
    },

Advanced reference qualifier for Org Number variable: 
 
Javascript: new setSubAccount.getOrgAndSubAccountValues(current.siu_fund)

 

 

Similarly try creating a new function for sub account and in reference qualifier call that function.

 

Note: Try to follow the best practice so to store the sys id in system property and then call in your script include

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,

Swathi Sarang

Hi @swathisarang98 

I tried :

 

Script Include:

 

var setSubAccount = Class.create();
setSubAccount.prototype = {
    initialize: function() {},
    getOrgValues: function(siuValue) {
        var orgValues = ["c374861c1b4ba5108e9987f5624bcbb9", "0b74861c1b4ba5108e9987f5624bcbc1"];

        if (siuValue === "D") {
            return "sys_idIN" + orgValues.join();
           
        }
    },

    getSubAccountValues: function(siuValue) {
        var subAccountValues = ["9ba60e9c1b4ba5108e9987f5624bcb22"];

        if (siuValue === "D") {
            return "sys_idIN" + subAccountValues.toString();
        }
    },

    type: 'setSubAccount'
};
 
Advanced Reference Qualifier:
 
Org Number: javascript: new setSubAccount.getOrgValues(current.siu_fund);
Sub Account: javascript: new setSubAccount.getSubAccountValues(current.siu_fund);
 
But no luck. Please help me further.

Hi @Rekha20 ,

 

I have noted few points, try doing below steps,

1.remove join() add toString()

2.Try adding gs.info in every step to check whether the value is coming or not 

3.remove === keep ==

4.check backend value of "D"

5.check the backend name of all the fields

 

and please screenshots of the error you are getting 

swathisarang98_0-1708426044591.png

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

Hi @swathisarang98 

Here is the updated SI:

 

var setSubAccount = Class.create();
setSubAccount.prototype = {
    initialize: function() {gs.log("Rtiwari "+ "11");},
    getOrgValues: function(siuValue) {
        gs.info("Rtiwari "+ "1");
        var orgValues = ["c374861c1b4ba5108e9987f5624bcbb9", "0b74861c1b4ba5108e9987f5624bcbc1"];
        if (siuValue == "D") {
            gs.info("Rtiwari "+ "11");
            return "sys_idIN" + orgValues.toString();
           
        }
    },

    getSubAccountValues: function(siuValue) {
        gs.info("Rtiwari "+ "2");
        var subAccountValues = ["9ba60e9c1b4ba5108e9987f5624bcb22"];

        if (siuValue == "D") {
            gs.info("Rtiwari "+ "22");
            return "sys_idIN" + subAccountValues.toString();
        }
    },

    type: 'setSubAccount'
};
 
There is no log coming in log table, neither any error.