Set field value true if the caller field has a particular person

Community Alums
Not applicable

On an interaction, I have a field name 'u_external_user'. It is a checkbox (True/False).

I want to toggle this field True if the Opened for field 'opened_for' is a user named External User. I believe a client script will be the best way to do this but need advice on this and code if anyone can help.

1 ACCEPTED SOLUTION

Shamma Negi
Kilo Sage
Kilo Sage

if(g_form.getValue("opened_for") == "sys id of the external user)

{

g_form.setValue("<external_user_checkbox" , true);

}

else

 

{

g_form.setValue("<external_user_checkbox" , false);

}

Regards,Shamma Negi

View solution in original post

23 REPLIES 23

Anurag Tripathi
Mega Patron
Mega Patron

Hi Shannon,

A client script would do but how do you identify an external user?

If you have any field on the user table that will tell you that the user is external then you can use this

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var ref = g_form.getReference('<opened for>', getUserRec); //assuming caller is opened_for
    }
function getUserRec(ref) {
                g_form.setValue('u_external_user', ref.<field on user that showes he is external user>);
    }
}
-Anurag

Community Alums
Not applicable

We have created a user account called External User. When selected, I want to toggle this checkbox true because it makes visible fields to store the external user's information. 

Hi,

So if I understand, if you select 'External User' as called on interaction then you want to toggle a checkbox

 

if I understood correct then you can do something like this

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
if(g_form.getDisplayBox('<opened for>').value)  == 'External User'  //assuming caller is opened_for
{
 g_form.setValue('<field to toggle>', <value>); //when caller is external user
}
else{
 g_form.setValue('<field to toggle>', <value>); //when caller is NOT external user
}
    }
-Anurag

Hi @Community Alums ,

 

Why not create a UI Policy? If caller is External user, then show XXXX fields. This is OOTB configuration and no scripting is needed.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/