Contact Number is not populating on Record Producer in Service Portal

SNOW46
Tera Contributor

Hello Team,

I have configured a variable named Contact Number for a record producer in Service Portal for creating a new Incident.

But unfortunately the Contact Number is not getting auto-populated when the form loads. And also when I change the Caller Name I need to remove the number which is populated and populate the Caller's Number in that field.

find_real_file.png

find_real_file.png

 

 

Can anyone let me know how to configure the same?

 

Thanks in Advance...

1 ACCEPTED SOLUTION

@SNOW

Was not able to login to community yesterday all day. Please find the solution below on how you can achieve your last bit of requirement as well:

Just write a catalog UI Policy on your Record Producer and clear out the value of your Contact Number field. Steps shown below:

No Script required:

find_real_file.png

find_real_file.png

Save the Form and scroll down to Catalog UI Actions and click on new and select the Contact Number field and then make sure to check the Clear value field as shown below:

find_real_file.png

This is working for me. 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

18 REPLIES 18

Monika13
Giga Expert

Hi,

Write client script onchange of caller name.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        g_form.clearValue('contact');
        return;
    }
  var ga = new GlideAjax('getUserDetails');
    ga.addParam('sysparm_name', 'getUserInformation');
    ga.addParam('sysparm_user_id', g_form.getValue('caller_id'));
    ga.getXML(parseUserResponse);
//alert("test");
    function parseUserResponse(response) {
         var answer = response.responseXML.documentElement.getAttribute("answer");
      // alert(answer);
		g_form.setValue("contact",answer);
		
    }

Script include

var getUserDetails = Class.create();
getUserDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getUserInformation: function() {
        var user_sys_id = this.getParameter('sysparm_user_id');
	var user = new GlideRecord('sys_user');
        user.get(user_sys_id);
        if (user.next()) {
			var mob=user.mobile_number;
           return mob;
        }
    },
    type: 'getUserDetails'

});

shloke04
Kilo Patron

Hi @SNOW

You do not need to do much of scripting here to get this requirement done and can be done with OOB functionality which is mostly configurable:

1) In your Caller Variable, open the Variable record and add the below line of code in the default value of caller which will default it to current logged in User :

javascript:gs.getUserID();

find_real_file.png

Now to get the Phone Number of current logged in User, create a Script Include and use the script as below:

var getContact = Class.create();
getContact.prototype = {
    initialize: function() {},

    getDetails: function() {
        var gr = new GlideRecord('sys_user');
        gr.addQuery('sys_id', gs.getUserID());
        gr.query();
        if (gr.next()) {
            return gr.mobile_phone.toString();

        }

    },

    type: 'getContact'
};

Screenshot of Script Include:

find_real_file.png

Now in Contact Number Variable add the below line of code in the Default value as shown below:

javascript:new getContact().getDetails()

 

The above things will take care of your On Load Functionality . Now for your On Change you do not need any scripting at all and with just few configurations you can do this as per steps mentioned below:

1) In your record producer form scroll down and Navigate to Related List named as "Catalog Data Look Uop Definitions" as shown below:

find_real_file.png

Click on NEW button and configure it as shown below and save the record once done.

find_real_file.png

Scroll down and click on New on the Related List named as "Catalog Matcher Variable Definition" as shown below and configure it as below:

find_real_file.png

And on the other Related List named as "Catalog Setter Variable Definition" as shown below and click on New and configure it as shown below:

find_real_file.png

Follow each step carefully and you will be dine with your requirement. It is working for me and have tested it in my PDI.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

SNOW46
Tera Contributor

Hello Shloke,

Nice it worked for me really!!! 

 

But I have one doubt here like if I clear the Caller Name from Caller ID field the mobile number is not getting removed.It is staying as it is and once I replace with another Caller Name it populates the mobile number associated with that new Caller Name.

Thanks

SNOW46
Tera Contributor

Hello Shloke,

Can you please help me out as I am struggling on the last part only.Please help me out.

 

Thanks

SNOW46
Tera Contributor

Hello Shloke,

I am still awaiting your response on my query addressed. Please provide me the final step resolution so that I can apply the fix in my configurations.

 

Thanks