Confirm popup on submit

Kim Jenson
Kilo Contributor

Hello experts,

So I'm trying to get a confirmation pop up to work onSubmit off a referenced field in a SCOPED APP. I want to say get the display value from the 'source' field and put it in the confirm box. I've checked to make sure the display is 'true' for 'name' on source table. trying this following code, but not working for me.

If I do getValue('source'), then I get a sysid back, so that tells me since it's a reference, I need to dot walk it. But can't seem to figure it out. Please help! Thanks.

function onSubmit() {

  var source = g_form.getDisplayValue('source.name');

  var confirm = confirm("Are you sure "+ source + " is correct?");

  if (confirm == false){

  return false;

  }

}

23 REPLIES 23

this works, but i'm back to the same error i was getting after clicking OK ..



Screen Shot 2017-06-19 at 9.33.53 PM.png


Hi Kim,



getDisplayValue() method is used to   return the display value of the reference field. However this is not supported at client side, hence you have to make a GlideAjax call and then return the response. More info here.


http://wiki.servicenow.com/index.php?title=GlideAjax



Regards,


Sachin


Steven Young
Tera Guru

you can do a g_form.getReference('value').name;    



where name is the "Name" field on the referenced table.


Hi Steven, this did not work


Hi Kim,



Use below script



function onSubmit() {


var myVal= g_form.getReference('source',


function doAlert(source) {


return source.name;


}


);



var confirm = confirm("Are you sure "+ myVal + " is correct?");


  if (confirm == false){


  return false;


  }


}



Please mark this response as correct or helpful if it assisted you with your question.