Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

No Preview avaible for user field

ash_1998
Tera Contributor

I have a requirement to autopopulate opened for user name  which is present in employee relation case form . i need to populate opened for name  in  involved party form "user" field based on reporter dropdown selec from "type"          i write a below script. But in user field its showing "No Preview available.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var ty = g_form.getValue("type");
    alert(ty);
    if (ty == "46d44a23a9fe19810012d100cca80666") {
        var userref = g_form.getReference('hr_case', userLookup);
        alert(userref);
    }

    function userLookup(userref) {
        g_form.setValue('user', userref.opened_for.toString());

 

 

1 ACCEPTED SOLUTION

Harsh_Deep
Giga Sage
Giga Sage

Hello @ash_1998 ,

 

Please use glideAjax (Script Include) for the same.

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

View solution in original post

4 REPLIES 4

Harsh_Deep
Giga Sage
Giga Sage

Hello @ash_1998 ,

 

Please use glideAjax (Script Include) for the same.

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

Thank you. its working by using Script include

Aniket Chavan
Tera Sage
Tera Sage

Hello @ash_1998,

Please give a try with the script below and let me know how it works for you.
onChange Client Script: 

 

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

    var ty = g_form.getValue("type");

    if (ty == "46d44a23a9fe19810012d100cca80666") {
        var userref = g_form.getReference('opened_for', userLookup);
    }

    function userLookup(userref) {
        if (userref) {
            g_form.setValue('user', userref.name.toString());
        } else {
            alert('User reference not found.');
        }
    }
}

 


Additionally if you still face the issue with "No preview available" then please let me know or if it worked then I would suggest to create one system property and store your sys_id there and then create one script include and use that in client script to avoid the using sys_id directly in the scripts or else you can you one Display BR as well but before that firstly check how the current script works .


Mark
Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

Thank you  for your response Aniket. by using script include its working well