<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Look-up record from GlideModalForm in Community Central forum</title>
    <link>https://www.servicenow.com/community/community-central-forum/look-up-record-from-glidemodalform/m-p/3102627#M1614</link>
    <description>&lt;P&gt;Hello Community,&lt;BR /&gt;&lt;BR /&gt;I am trying to create a UI Action that uses a GlideModalForm to display an asset from the alm_hardware or alm_asset table and allow updates to that asset.&lt;BR /&gt;&lt;BR /&gt;My question is how to you take the input value from the modal and display the particular record in the form?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can do the pop-up, but I can't load a specific asset into the form.&amp;nbsp; &amp;nbsp;How is this done?&amp;nbsp; Do you use the setPreference('sysparam_query') method and if so, what is the query value for alm_hardware.asset_tag?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function scan_hardware(){
var gm = new GlideModal("glide_prompt", true, 600);
gm.setTitle("Scan Hardware");
gm.setPreference("title", "Asset Tag:");
gm.setPreference("onPromptComplete", function(value) {
	var af= new GlideModalForm("Update Asset",'alm_asset');
        var query = 'asset_tag' +value; //building the query string but I think this is the issue??
        af.setPreference('syspram_query', query); 
        af.setPreference('install_status',1); //set state to in use
	af.render();
});
gm.setPreference("onPromptCancel", function(value) {alert("You clicked on 'Cancel', value was: "+value)});
gm.render();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 12 Nov 2024 17:58:27 GMT</pubDate>
    <dc:creator>JGerrity</dc:creator>
    <dc:date>2024-11-12T17:58:27Z</dc:date>
    <item>
      <title>Look-up record from GlideModalForm</title>
      <link>https://www.servicenow.com/community/community-central-forum/look-up-record-from-glidemodalform/m-p/3102627#M1614</link>
      <description>&lt;P&gt;Hello Community,&lt;BR /&gt;&lt;BR /&gt;I am trying to create a UI Action that uses a GlideModalForm to display an asset from the alm_hardware or alm_asset table and allow updates to that asset.&lt;BR /&gt;&lt;BR /&gt;My question is how to you take the input value from the modal and display the particular record in the form?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can do the pop-up, but I can't load a specific asset into the form.&amp;nbsp; &amp;nbsp;How is this done?&amp;nbsp; Do you use the setPreference('sysparam_query') method and if so, what is the query value for alm_hardware.asset_tag?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function scan_hardware(){
var gm = new GlideModal("glide_prompt", true, 600);
gm.setTitle("Scan Hardware");
gm.setPreference("title", "Asset Tag:");
gm.setPreference("onPromptComplete", function(value) {
	var af= new GlideModalForm("Update Asset",'alm_asset');
        var query = 'asset_tag' +value; //building the query string but I think this is the issue??
        af.setPreference('syspram_query', query); 
        af.setPreference('install_status',1); //set state to in use
	af.render();
});
gm.setPreference("onPromptCancel", function(value) {alert("You clicked on 'Cancel', value was: "+value)});
gm.render();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 17:58:27 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/look-up-record-from-glidemodalform/m-p/3102627#M1614</guid>
      <dc:creator>JGerrity</dc:creator>
      <dc:date>2024-11-12T17:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Look-up record from GlideModalForm</title>
      <link>https://www.servicenow.com/community/community-central-forum/look-up-record-from-glidemodalform/m-p/3102869#M1616</link>
      <description>&lt;P&gt;Thought I'd update myself.&lt;BR /&gt;&lt;BR /&gt;Thanks to&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/383281"&gt;@ericgilmore&lt;/a&gt;&amp;nbsp;for posting something that made me think in the right direction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We need to find the sys_ID of the record from the modal prompt: (value is the variable name of the prior GlideModal"glide_prompt" I call earlier in below.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var gr = new GlideRecord('alm_asset');
    gr.addQuery('asset_tag', value);
	gr.query();
    if (gr.next()) {
        var aTag = gr.sys_id; 
		}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you can use .setSysID to set the sys_ID and refer to that particular record:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var af= new GlideModalForm('Update Asset','alm_asset');
	af.setSysID(aTag);
	af.setPreference('alm_asset.install_status',1); //set state to in use
	af.setPreference('alm_asset.assigned_to', currentUser);
	af.render();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This now works and my GlideModalForm refers to the specific asset_tag.&amp;nbsp; Thanks Eric!&lt;BR /&gt;&lt;BR /&gt;Now I'm trying to set some field values in advance of the loaded asset form and I thought .setPreference was the way to achieve this, but it's not working...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;af.setPreference('alm_asset.install_status',1); //set state to in use
	af.setPreference('alm_asset.assigned_to', currentUser);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried .setPreference('install_status',1) and 'state' but to no avail.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thoughts anyone?&lt;BR /&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2024 14:29:55 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/look-up-record-from-glidemodalform/m-p/3102869#M1616</guid>
      <dc:creator>JGerrity</dc:creator>
      <dc:date>2024-11-13T14:29:55Z</dc:date>
    </item>
  </channel>
</rss>

