Pop Up window to confirm and also used to update a record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2010 04:10 AM
I am trying to create a script for Pop Up window to confirm and also used to update a record. Basically I want this script on the sc_task table to be an on submit so that it will pop up ok/cancel box and If they select ok, it will update a field on the sc_req_item (request Item) table. If they hit cancel, it will just perform the save/update function.
Since I am not very good at scripting, I have attempted a simple script but of course it does not seem to work or at least does not update the backordered field on the sc_req_item (request Item) table .
Ran on the sc_task table:
function onSubmit() { var answer = confirm ("Does this need to be ordered? \n \n Click OK if this needs to be ordered \n \n Click Cancel if you do not need to order"); if (answer){ alert ("Order request has been sent to Purchasing."); var gr = new GlideRecord("sc_req_item"); gr.addQuery("request", current.sys_id); gr.query(); while(gr.next()) { gr.backordered.setDisplayValue('true'); } } else{ alert ("Proceed to the next Task."); // g_form.setValue ('current.sc_req_item.backordered, false'); } }
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2010 04:51 AM
If its easier I would like to have a ordered required Yes/No field on the sc_task (Catalog task) table and when updated, it will updat the backordered box on the sc_req_item (Request Item) table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2010 07:06 AM
figured it out, now all i have to do is to make this also work if the user clicks the close task button.
function onSubmit() {
var desc = g_form.getValue('short_description');
var state = g_form.getValue('state');
if ((desc=='PC Accessory - Check Stock or Order from vendor') && (state=='3')){
var answer = confirm ("Does this need to be ordered? \n \n Click OK if this needs to be ordered \n \n Click Cancel if you do not need to order");
if (answer){
alert ("Order request has been sent to Purchasing.");
g_form.setValue('request_item.backordered', 'true');
// gsftSubmit(gel('sysverb_update_and_stay'));
//gsftSubmit(gel('sysverb_update'));
}
else{
// alert ("Proceed to the next Task.");
// g_form.setValue('u_backordered', 'false');
//gsftSubmit(gel('sysverb_update_and_stay'));
// g_form.setValue ('current.sc_req_item.backordered, false');
}
}
}