Verify Contact and Verify Consumer UI action client script
- UpdatedAug 3, 2023
- 2 minutes to read
- Vancouver
- Navigation and UI
The Vancouver release is no longer supported. As such, the product documentation and release notes are provided for informational purposes only, and will not be updated.
The lookup and verify feature uses a client script for the Verify Contact and Verify Consumer UI actions.
The main function that calls the lookup and verify modal has been changed in the Orlando release. The g_csm.lookupAndVerify function call was replaced by g_modal.sn_lookup_verify.lookupVerify. The call back handling has also changed.
If you modified the lookup and verify UI action script in the Madrid or New York releases, you need to modify the script for the Orlando release. It is not updated automatically during the upgrade to Orlando. You can use the examples below to make the necessary changes.
Client script for the Verify Contact UI action (Orlando)
function onClick(g_form) {
if (!g_form.isVisible("contact")) {
var msg = "You do not have permissions to verify the contact.";
getMessages([msg], function(messages) {g_form.addErrorMessage(messages[msg]);});
return;
}
var title = "Verify Contact";
var confirm_title = "Done";
var cancel_title = "Cancel";
getMessages([title, confirm_title, cancel_title], function(messages) {
var lookupConfig = {
configID: '0a20d0c9b360230001f34d43c6a8dc0a',
selectedEntityTableName: 'customer_contact',
selectedEntitySysID: g_form.getValue('contact'),
selectedEntityDisplayVal: g_form.getDisplayValue('contact'),
modalTitle: messages[title]
};
g_modal.sn_lookup_verify.lookupVerify({
title: messages[title],
confirmTitle: messages[confirm_title],
cancelTitle: messages[cancel_title],
params: lookupConfig,
disabledPrimaryButtonOnLoad: true,
size: 'lg'
}).then(
function(confirm) {
var data = confirm.data;
var verifiedSysId = data.sysId;
g_form.setValue('account', '');
g_form.setValue('contact', verifiedSysId);
g_form.setValue('verified', 'true');
var ga = new GlideAjax('global.CSManagementUtils');
ga.addParam('sysparm_name', 'getGlideRecordData');
ga.addParam('sysparm_table_name', "customer_contact");
ga.addParam('sysparm_sys_id', verifiedSysId);
ga.addParam('sysparm_fields', "account");
ga.getXML(function(serverResponse){
var items = serverResponse.responseXML.getElementsByTagName("item");
for(var i = 0; i < items.length; i++) {
var field = items[i].getAttribute("field");
if (field == "account") {
g_scratchpad.csaccountset = true;
g_form.setValue("account", items[i].getAttribute("value"), items[i].getAttribute("display_value"));
break;
}
}
var info = "This contact has been verified.";
getMessages([info], function(messages) {g_form.addInfoMessage(messages[info], 'info', "");});
if (data.stringForLookup) {
var interactionId = g_form.getUniqueValue();
var ga = new GlideAjax('sn_lookup_verify.LookupVerifyUtil');
ga.addParam('sysparm_name', 'associateRecordToInteraction');
ga.addParam('sysparm_term', data.stringForLookup);
ga.addParam('sysparm_interaction_id', interactionId);
ga.getXMLAnswer(function(answer){
var result = JSON.parse(answer);
if (result != null && result.table != null && result.sysId != null) {
var params = {};
params.sysparm_parent_table = "interaction";
params.sysparm_parent_sys_id = g_form.getSysId();
g_service_catalog.openCatalogItem(result.table, result.sysId, params);
}
});
}
});
},
function(error) {
console.log('cancel:'+error);
}
);
});
}
Client script for the Verify Contact UI action (New York)
function onClick(g_form) {
if (!g_form.isVisible("contact")) {
var msg = "You do not have permissions to verify the contact.";
getMessages([msg], function(messages) {g_form.addErrorMessage(messages[msg]);});
return;
}
var title = "Verify Contact";
getMessages([title], function(messages) {
var lookupConfig = {
configID: '0a20d0c9b360230001f34d43c6a8dc0a',
selectedEntityTableName: 'customer_contact',
selectedEntitySysID: g_form.getValue('contact'),
selectedEntityDisplayVal: g_form.getDisplayValue('contact'),
modalTitle: messages[title]
};
var onConfirm = function(data) {
var verifiedSysId = data.sys_id;
g_form.setValue('account', '');
g_form.setValue('contact', verifiedSysId);
g_form.setValue('verified', true);
var ga = new GlideAjax('global.CSManagementUtils');
ga.addParam('sysparm_name', 'getGlideRecordData');
ga.addParam('sysparm_table_name', "customer_contact");
ga.addParam('sysparm_sys_id', verifiedSysId);
ga.addParam('sysparm_fields', "account");
ga.getXML(function(serverResponse){
var items = serverResponse.responseXML.getElementsByTagName("item");
for(var i = 0; i < items.length; i++) {
var field = items[i].getAttribute("field");
if (field == "account") {
g_scratchpad.csaccountset = true;
g_form.setValue("account", items[i].getAttribute("value"), items[i].getAttribute("display_value"));
break;
}
}
var info = "This contact has been verified.";
getMessages([info], function(messages) {g_form.addInfoMessage(messages[info], 'info', "");});
if (data.stringForLookup) {
var interactionId = g_form.getUniqueValue();
var ga = new GlideAjax('sn_lookup_verify.LookupVerifyUtil');
ga.addParam('sysparm_name', 'associateRecordToInteraction');
ga.addParam('sysparm_term', data.stringForLookup);
ga.addParam('sysparm_interaction_id', interactionId);
ga.getXMLAnswer(function(answer){
var result = JSON.parse(answer);
if (result != null && result.table != null && result.sysId != null) {
var params = {};
params.sysparm_parent_table = "interaction";
params.sysparm_parent_sys_id = g_form.getSysId();
g_service_catalog.openCatalogItem(result.table, result.sysId, params);
}
});
}
});
};
g_csm.lookupAndVerify(lookupConfig, onConfirm);
});
}