Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Virtual agent decision based on the user

M_iA
Kilo Sage

Probably really simple one this where im having a moment!

I have a topic decision that I am trying to build that looks at a reference field on the users company record and depending on the answer, will take the user on the specific journey.

 

M_iA_0-1731929143142.png

 

Each branch script condition script has the following with the relevant sys_id:

 

(function execute() {
if (vaInputs.user.company.u_support_tier == '583d8e3e1bcfe5901b8eec69b04bcbca')
    return true;
})()

 

But this doesnt seem to work! Please could someone point me in the right direction for this?

Many thanks

1 ACCEPTED SOLUTION

M_iA
Kilo Sage

I achieved this in the end by doing an initial script utility before the decision:

(function execute() {
    var gr = new GlideRecord('sys_user');
    gr.addQuery('sys_id', vaInputs.user.sys_id); 
    gr.query();

    if (gr.next()) {
        var supportTier = gr.company.u_support_tier.getDisplayValue();
        //gs.info('M_iA Support Tier: ' + supportTier); 
        vaVars.supportTier = supportTier;
    } else {
        //gs.info('M_iA No user found with sys_id: ' + vaInputs.user.sys_id); 
    }
})();

and then for each descision, I had the following:

 

(function execute() {
    //gs.info('M_iA Support Tier: ' + vaVars.supportTier); 

    if (vaVars.supportTier == 'Essential UK' || vaVars.supportTier == 'Essential ROI') {
        return true;
    } else {
        return false;
    }
})();

View solution in original post

1 REPLY 1

M_iA
Kilo Sage

I achieved this in the end by doing an initial script utility before the decision:

(function execute() {
    var gr = new GlideRecord('sys_user');
    gr.addQuery('sys_id', vaInputs.user.sys_id); 
    gr.query();

    if (gr.next()) {
        var supportTier = gr.company.u_support_tier.getDisplayValue();
        //gs.info('M_iA Support Tier: ' + supportTier); 
        vaVars.supportTier = supportTier;
    } else {
        //gs.info('M_iA No user found with sys_id: ' + vaInputs.user.sys_id); 
    }
})();

and then for each descision, I had the following:

 

(function execute() {
    //gs.info('M_iA Support Tier: ' + vaVars.supportTier); 

    if (vaVars.supportTier == 'Essential UK' || vaVars.supportTier == 'Essential ROI') {
        return true;
    } else {
        return false;
    }
})();