Email displaying email of the user from user table instead of custom saved

Dave_p
Giga Guru

Hi,

I have a scenario, where in I have saved a new notification contact via form which subsequently gets saved in the 'file share' table, but when i try to reuse the same file, it is taking the notification contact from the 'user' table. I will share every screenshot. Kindly help.

 

1.png

 

2.png

 

Here in above, I selected a particular file share and we can see that I selected "Aaliyah" as the 'New Primary Approver' and the corresponding 'New Notification Contact' I entered custom email as "a@abc.com". Once I create RITM, we have something like this.

 

3.png

 

When I go the file share table, I have something like this below for the same file share

 

4.png

 

Now we know that the new file share table has "a@abc.com"  saved.

 

Now, I create a new record by opening the form again and selecting the same file share, as per our understanding, we should have 'New Notification Contact' as a@abc.com". But, it is showing Aliyah's user email as the 'New Notification Contact' instead of custom email "a@abc.com"

 

Dave_p_0-1750838443712.png

I have created the following client scripts.

 

GlideAjax

 

6.png

 

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

    if (newValue == "") {
        g_form.setValue('current_primary_approver', "");
        g_form.setValue('share_type', "");
        g_form.setValue('protocol_type_new', "");
    } else {

        var sp = g_form.getValue('share_path');
        var ga = new GlideAjax('populate_modify_network_class');
        ga.addParam('sysparm_name', 'populate_modify_network_function');
        ga.addParam('sysparm_share', sp);
        ga.getXML(callBackFunction);

        function callBackFunction(response) {
            var answer = response.responseXML.documentElement.getAttribute("answer");
            var op = JSON.parse(answer);
            g_form.setValue('share_type', op.shareType);
            g_form.setValue('protocol_type_new', op.protocol_type);
            g_form.setValue('current_primary_approver', op.primary);
        }
    }
}

 

Script Include

 

7.png

 

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

    populate_modify_network_function: function() {
        var obj = this.getParameter('sysparm_share');
        var arrayss = {};
        var grec = new GlideRecord('u_cmdb_ci_file_share');
        grec.addQuery('sys_id', obj);
        grec.query();
        if (grec.next()) {
            arrayss.primary = grec.managed_by.toString();
            arrayss.shareType = grec.u_type.getDisplayValue();
			//if condition for protocol
            if (grec.u_protocol.toString() == 'windows_only')
                arrayss.protocol_type = 'windows';
            else
                arrayss.protocol_type = 'multiprotocol';
        }

        return JSON.stringify(arrayss);
    },

    type: 'populate_modify_network_class'
});

 

GlideAjax

 

8.png

 

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


   var ga = new GlideAjax('current_Notification_Contact_Class');
   ga.addParam('sysparm_name', 'current_Notification_Contact_function');
   ga.addParam('sysparm_id', g_form.getValue('current_primary_approver'));
   ga.getXML(callBackFunction);
   function callBackFunction(response){
	var answer = response.responseXML.documentElement.getAttribute('answer');
	g_form.setValue('current_notification_contact', answer);
   }  
}

 

Script Include

 

9.png

 

var current_Notification_Contact_Class = Class.create();
current_Notification_Contact_Class.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	current_Notification_Contact_function: function(){
		var email_Ans = this.getParameter('sysparm_id');
		var gr = new GlideRecord('sys_user');
		gr.addQuery('sys_id', email_Ans);
		gr.query();
		if(gr.next()){
			var em = gr.getValue('email');
			return em;
		}
		
	},

    type: 'current_Notification_Contact_Class'
});

 

Regards

Suman P.

 

1 REPLY 1

Muhammad Salar
Giga Sage

Hi @Dave_p , What is the business requirement here?
If you have manually written New Notification Contact as first for new record then how can it be populated automatically for next new record?
Or next record is a update type?
Or you are populating New Notification Contact by any script ?