get reference

tghadage124
Tera Contributor

Hi guys , 

 

here I am trying to display a message " please look into it urgently as its issue related to VIP user when caller is VIP "  and priority is one on submit but its not going inside the loop to check can you please help you figure out if I am checking it correctly.

 

function onSubmit() {
    //Type appropriate comment here, and begin script below

    var user = g_form.getReference('caller_id',getcaller);
    var pri = g_form.getValue('priority');

    function getcaller(user) {

        if (user == 'vip' && pri == 1) {

            g_form.addErrorMessage('please look into it urgently as its issue related to VIP user');

        } else {
            g_form.addInfoMessage('everything looks good as of now');
        }

    }

}
7 REPLIES 7

Community Alums
Not applicable

Hi @tghadage124 

Please make changes in the script as user.vip == "true" instead of user = vip.

Please mark it helpful and correct , if it helps.

Brad Bowman
Kilo Patron
Kilo Patron

It's probably hoisting the 'pri' variable, but I wouldn't count on it, so it's safer to put it first - and you need to use the correct syntax in the getReference callback

function onSubmit() {
    var pri = g_form.getValue('priority');
    var user = g_form.getReference('caller_id',getcaller);

    function getcaller(user) {
        if (user.vip == 'true' && pri == 1) {
            g_form.addErrorMessage('please look into it urgently as its issue related to VIP user');
        } else {
            g_form.addInfoMessage('everything looks good as of now');
        }
    }
}

you were correct , its the hosting of the pri variable , it worked ,thanks

Amit Verma
Kilo Patron
Kilo Patron

Hi @tghadage124 

 

The problem in your script is the way you are trying to check the VIP user. Refer below updated script and give it a try :

function onSubmit() {
    //Type appropriate comment here, and begin script below
    var pri = g_form.getValue('priority');
    var user = g_form.getReference('caller_id',getcaller);
   
    function getcaller(user) {

        if (user .vip == 'true' && pri == 1) {

            g_form.addErrorMessage('please look into it urgently as its issue related to VIP user');

        } else {
            g_form.addInfoMessage('everything looks good as of now');
        }

    }

}

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.