How to call email address from Sys Prop. to ctalog variable.

Puneet4418
Tera Contributor

Hi,

for a custom application we have created a record producer, in the form we have a choice field(wd_list) having 4 choices and a single line text(email_list) field. Now the requirement is, for every choice selected in the wd_list we want to copy email address in email_list field.

I have already created 4 sys properties storing the required email addresses. Now, I am stuck at copying the email addresses to the email_list field.
 please assist.

5 REPLIES 5

Najmuddin Mohd
Mega Sage

Hello @Puneet4418 ,

There's a better approach to this. Just let the end user select the choices and in the Record producer script, get the Choices selected and map the email addresses to the field using gs.getproperty().

If you want your end users to see the email_list field, then you need to write a on_change client script and use GlideAjax to get the Property and add in the email_list field.


If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.

@Najmuddin Mohd Thanks for your response.

 

I am trying with second approach. I have created a script include and calling that in On-Change catalog client script. However, it is not working.

Hello @Puneet4418 

 

Please share your client script and script include screenshot. 

Hi @Shivalika ,

 

Script Include:

 

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

getDLList: function(cellName) {
var propName = '';
var dlList = '';

switch (cellName) {
case 'Choice1':
propName = 'Property1';
break;
case 'Choice2':
propName = 'Property2';
break;
case 'Choice3':
propName = 'Property3';
break;
case 'Choice4':
propName = 'Property4';
break;
default:
return '';
}

var gr = new GlideRecord('sys_properties');
if (gr.get('name', propName)) {
dlList = gr.getValue('value');
}

return dlList;
}
});

 

 

 

Client Script:

 

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var dlListField = g_form.getField('email_list');
var ga = new GlideAjax('mgfdlcatcher');
ga.addParam('sys_id', g_form.getUniqueValue());
ga.addParam('cellName', newValue);
ga.getXMLAnswer(function(response) {
var dlValue = response.responseXML.documentElement.getAttribute("answer");


g_form.setValue(dlListField, dlValue);
});
}