OnChange Client Script on Assigned to field returns sys_id... How to get Display Value of AssignedTo

captsiddu
Tera Contributor

Hi Team, I want to alert when Assigned To field is changed. For that I have return onChanage Client Script on Assigned To field.

______________________________________________________________________

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    alert(newValue);

}
----------------------------------------------------------------------------------------
But when  Assigned To field is changed, I'm getting Sys Id of user in Alert..
How can I alert User name..???

2 ACCEPTED SOLUTIONS

Animesh Das2
Mega Sage

Hi @captsiddu ,

 

Since you want the newValue (not yet saved into the database), you can use,

alert(g_form.getDisplayBox('assigned_to'));

 

If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das

View solution in original post

Moin Kazi
Kilo Sage
Kilo Sage

Hi @captsiddu ,

 

Please use below code it will return assigned to name -

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    alert(g_form.getReference('assigned_to').name);
}

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.

 

Thank you!
Moin Kazi
www.linkedin.com/in/moinuddinkazi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View solution in original post

3 REPLIES 3

Animesh Das2
Mega Sage

Hi @captsiddu ,

 

Since you want the newValue (not yet saved into the database), you can use,

alert(g_form.getDisplayBox('assigned_to'));

 

If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das

Hi Animmesh, I did little changes to your code and it worked fine.

alert(g_form.getDisplayBox('caller_id').value);
 
Thank You!!

Moin Kazi
Kilo Sage
Kilo Sage

Hi @captsiddu ,

 

Please use below code it will return assigned to name -

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    alert(g_form.getReference('assigned_to').name);
}

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.

 

Thank you!
Moin Kazi
www.linkedin.com/in/moinuddinkazi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~