- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2021 10:06 AM
I have a button Approval on XYZ form.
If I click on Approval button while Client is selected and onClick event as emailClientOpenPop('sc_task'); it open the Email Pop up perfectly.
But if I unchecked Client it hide the onClick option and I can change the current.u_status = 'Close'; on the XYZ form.
But actual requirement is both think Email Client Pop up and the status update should happen simultaneously.
So is it possible I can call Email Client pop up from script and at the same time it updates the status.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2021 09:26 PM
Hi,
Script looks good.
Did you try adding logs in script include
var UpdateRecord = Class.create();
UpdateRecord.prototype = Object.extendsObject(AbstractAjaxProcessor, {
updateMyRecord: function(){
var sysId = this.getParameter('sysparm_id');
gs.info('sysId' +sysId);
var tableName = this.getParameter('sysparm_table');
var gr = new GlideRecord('XYZ');
gr.addQuery("sys_id", sysId);
gr.query();
if (gr.next()) {
gs.info('Record found');
gr.u_status = 'Approved';
gr.update();
}
},
type: 'UpdateRecord'
});
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2021 10:15 AM
Hi,
Can you please share your current UI action script?
Thank you
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2021 10:33 AM
Hi ashish,
Try this, Both client and server will run at the same time using gsftsubmit() in UI action
function validateForm() { //on-click function, here validateForm is the function name. you can change it accordingly
emailClientOpenPop('sc_task') //You can call emailClientOpenPop here, emailClientOpenPop function is defined in popups.js script
//Call the UI Action to run the server side script
gsftSubmit(null, g_form.getFormElement(), 'Give here unique UI Action name');
}
if(typeof window == 'undefined')
setStatus(); //Server function
function setStatus() {
current.u_status = 'Close';
current.update();
}
Best regards,
Sai Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2021 08:26 PM
Thank You Sai,I have updated below script in the UI Action but it is not opening Pop up thought is changing the status to Closed.
function validateForm() {
emailClientOpenPop('sc_task');
gsftSubmit(null, g_form.getFormElement(), 'Close_Action'); //Close_Action is UI Action Name
}
if(typeof window == 'undefined')
setStatus(); //Server function
function setStatus() {
current.u_status = 'Closed';
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2021 06:14 AM
Thank You Sai, It didn't worked and Ankur suggested something in Reply below. I am testing that as well.
It is opening Pop up absolutely fine but not able to change the status.
UI Action Name - Confirm_Status
Clicnt is Checked
onCLick - validateForm();
Script is -
function validateForm() { //
function validateForm() {
emailClientOpenPop('sc_task');
gsftSubmit(null, g_form.getFormElement(), 'Confirm_Status');
}
if(typeof window == 'undefined')
setStatus(); //Server function
function setStatus() {
current.u_status = 'Approved';
current.update();
action.setRedirectURL(current);
}
