<?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 Get all variables on a task form via script in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887131#M544057</link>
    <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to do something that may or may not be simple.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, we have mandatory fields on our Catalog Tasks for users to populate. Where we're at however, users will pass tasks between each other or try to assign them before populating the mandatory tasks. The problem we run into is once you go to a task, you can assign and save the record &lt;STRONG&gt;without&lt;/STRONG&gt; filling out those mandatory tasks. I'm trying to avoid making a UI policy for every mandatory task we have that says "be non mandatory unless the task state changes to Closed Complete". &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my question is: Is there a way to grab all mandatory variables off a Catalog Task form VIA Client script? Or at least grab all variables regardless of mandatory?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or even (hopefully?) simpler, is there a way to modify this code to grab all the variables in the map, then check if they are mandatory? If so, set them non mandatory? I've been banging my head against this for awhile and a scalable solution would be perfect so we don't have to create a new UI policy everytime we need a new variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11px; font-weight: bold; font-family: Monaco, 'Lucida Console', monospace; color: #003366; background-position: initial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="_jivemacro_uid_14692177594347057 jive_macro_code jive_text_macro" data-renderedposition="297_8_1192_240" jivemacro_uid="_14692177594347057" modifiedtitle="true"&gt;&lt;P&gt;function onLoad(){&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; try{&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Get the 'Variables' section&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var ve = $('variable_map').up('table');&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Disable all elements within with a class of 'cat_item_option'&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ve.select('.cat_item_option', '.slushselectmtm', '.questionsetreference').each(function(elmt){&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //CURRENTLY this will make ALL variables read only. I would like something like the following&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //if(elmt.mandatory = true){&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setMandatory(false);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //}&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; elmt.disabled = true;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/P&gt;&lt;P&gt; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; catch(e){}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 22 Jul 2016 20:05:21 GMT</pubDate>
    <dc:creator>nickmayo</dc:creator>
    <dc:date>2016-07-22T20:05:21Z</dc:date>
    <item>
      <title>Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887131#M544057</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to do something that may or may not be simple.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, we have mandatory fields on our Catalog Tasks for users to populate. Where we're at however, users will pass tasks between each other or try to assign them before populating the mandatory tasks. The problem we run into is once you go to a task, you can assign and save the record &lt;STRONG&gt;without&lt;/STRONG&gt; filling out those mandatory tasks. I'm trying to avoid making a UI policy for every mandatory task we have that says "be non mandatory unless the task state changes to Closed Complete". &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my question is: Is there a way to grab all mandatory variables off a Catalog Task form VIA Client script? Or at least grab all variables regardless of mandatory?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or even (hopefully?) simpler, is there a way to modify this code to grab all the variables in the map, then check if they are mandatory? If so, set them non mandatory? I've been banging my head against this for awhile and a scalable solution would be perfect so we don't have to create a new UI policy everytime we need a new variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11px; font-weight: bold; font-family: Monaco, 'Lucida Console', monospace; color: #003366; background-position: initial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="_jivemacro_uid_14692177594347057 jive_macro_code jive_text_macro" data-renderedposition="297_8_1192_240" jivemacro_uid="_14692177594347057" modifiedtitle="true"&gt;&lt;P&gt;function onLoad(){&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; try{&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Get the 'Variables' section&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var ve = $('variable_map').up('table');&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Disable all elements within with a class of 'cat_item_option'&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ve.select('.cat_item_option', '.slushselectmtm', '.questionsetreference').each(function(elmt){&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //CURRENTLY this will make ALL variables read only. I would like something like the following&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //if(elmt.mandatory = true){&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setMandatory(false);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //}&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; elmt.disabled = true;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/P&gt;&lt;P&gt; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; catch(e){}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jul 2016 20:05:21 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887131#M544057</guid>
      <dc:creator>nickmayo</dc:creator>
      <dc:date>2016-07-22T20:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887132#M544058</link>
      <description>&lt;P&gt;You can write this in display business rule and then set them mandatory to false in your onload client script&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var mandatory_fields=[];&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var set = new GlideappVariablePoolQuestionSet();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; set.setRequestID('put your request item sys_id');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; set.load(); &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var vs = set.getFlatQuestions();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; for (var i = 0; i &amp;lt; vs.size(); i++) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if(vs.get(i).mandatory==true){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;mandatory_feilds.push(vs.get(i).getName());&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;g_scratchpad.mandataoryArray=mandatory_fields;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;In your client script use this&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for (i=0; i&amp;lt;g_scratchpad.mandatoryArray.length;i++){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;g_form.setMandataory(g_scratchpad.mandatoryArray[i],false);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Jul 2016 20:35:07 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887132#M544058</guid>
      <dc:creator>Abhinay Erra</dc:creator>
      <dc:date>2016-07-22T20:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887133#M544059</link>
      <description>&lt;P&gt;Abhinay,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;This is definitely helpful but it's not grabbing the actual variables for me. It's missing a couple for me (2 drop downs and a string)&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Is there any limitations with your script? For example, does it ignore variable sets?&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 16:57:42 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887133#M544059</guid>
      <dc:creator>nickmayo</dc:creator>
      <dc:date>2016-07-25T16:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887134#M544060</link>
      <description>&lt;P&gt;Nope, it should have grabbed all the variables which have mandatory set to true&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:18:42 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887134#M544060</guid>
      <dc:creator>Abhinay Erra</dc:creator>
      <dc:date>2016-07-25T17:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887135#M544061</link>
      <description>&lt;P&gt;Ah, I have found the issue.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;This only works for variables that are checked off as mandatory because its checking at display. The ones I need to change are being set to mandatory by a UI policy. Variables that are not mandatory by default will not work with this solution.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I'll see if I can re-work this to check after the UI policy.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thanks for the help!&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 18:07:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887135#M544061</guid>
      <dc:creator>nickmayo</dc:creator>
      <dc:date>2016-07-25T18:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887136#M544062</link>
      <description>&lt;P&gt;Ahh.. I do not think this will work with a display business rule. Since&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;display business rule is triggerred before a record is actually displayed.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I will recommend to use a glideajax in a client script and put the server&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;side script in a script include.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;On Monday, July 25, 2016, nickmayo &amp;lt;community-no-reply@servicenow.com&amp;gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 18:15:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887136#M544062</guid>
      <dc:creator>Abhinay Erra</dc:creator>
      <dc:date>2016-07-25T18:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887137#M544063</link>
      <description>&lt;P&gt;Try it and let me know if you have any questions.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 18:37:43 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887137#M544063</guid>
      <dc:creator>Abhinay Erra</dc:creator>
      <dc:date>2016-07-25T18:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887138#M544064</link>
      <description>&lt;P&gt;So I've got it to return the variables, but it's still only pulling ones thats are actually marked as mandatory vs ones changed to mandatory via UI policy.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I put it in an onChange script instead, but even if I run it after the page loads it doesn't pull the ones affected by the UI policy. Any suggestions? The code is running fine, but I think I just need to see if there is a way to check if a UI policy is affecting the variables. Below is my code so far:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Client Script:&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14694732913582830 jive_text_macro" data-renderedposition="134_8_1192_400" jivemacro_uid="_14694732913582830"&gt;&lt;P&gt;function onChange(control, oldValue, newValue, isLoading, isTemplate) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; if (isLoading || newValue == 3) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var ga = new GlideAjax('mandatoryVariables');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; ga.addParam('sysparm_name','MandatoryVariables');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; ga.addParam('sysparm_value', g_form.getValue('request_item')); //send RITM number&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; ga.getXML(ajaxResponse);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function ajaxResponse(serverResponse) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var result = serverResponse.responseXML.getElementsByTagName("result");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var message = result[0].getAttribute("message");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; if(message){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; alert(message);}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var output = "";&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var variables = serverResponse.responseXML.getElementsByTagName("variable");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; for (i=0; i &amp;lt; variables.length ; i++){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; //g_form.setMandatory(variables[i],false);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var name = variables[i].getAttribute("name");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; output += name + "\n" ;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; alert(output);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Script include:&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14694733573264563 jive_text_macro" data-renderedposition="576_8_1192_384" jivemacro_uid="_14694733573264563"&gt;&lt;P&gt;var mandatoryVariables = Class.create();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;mandatoryVariables.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; MandatoryVariables: function(){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var result = this.newItem("result");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; result.setAttribute("message", "returning mandatory variables");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var set = new GlideappVariablePoolQuestionSet();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; set.setRequestID(this.getParameter('sysparm_value'));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; set.load();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var vs = set.getFlatQuestions();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; for (var i = 0; i &amp;lt; vs.size(); i++) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; if(vs.get(i).mandatory==true){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; this._addVariable(vs.get(i).getName());&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; },&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; _addVariable : function(name) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var vars = this.newItem("variable");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; vars.setAttribute("name", name);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; },&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; type: 'mandatoryVariables'&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;});&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 19:02:44 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887138#M544064</guid>
      <dc:creator>nickmayo</dc:creator>
      <dc:date>2016-07-25T19:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887139#M544065</link>
      <description>&lt;P&gt;Bump - does anyone have any ideas here? &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;We need this functionality. I've found other threads where folks are adding UI actions and making all variables non mandatory, but I need only a couple marked as non mandatory. UI policies are not an option here.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 20:00:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887139#M544065</guid>
      <dc:creator>nickmayo</dc:creator>
      <dc:date>2016-07-25T20:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887140#M544066</link>
      <description>&lt;P&gt;Do you want to make everything as non-mandatory or only a specific variables?&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 20:34:01 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887140#M544066</guid>
      <dc:creator>Abhinay Erra</dc:creator>
      <dc:date>2016-07-25T20:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887141#M544067</link>
      <description>&lt;P&gt;Only specific variables i.e any variables that are set to mandatory by a UI policy.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Basically I need the functionality from the pop up that prevents you from saving a record when you have mandatory variables (the following mandatory variables have not been filled in pop up) but in my script so I can read variables that are set to mandatory from a policy and not the dictionary.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I need this because we add variables frequently and making UI policies for each variable is going to take far too long.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Sent from my Verizon, Samsung Galaxy smartphone&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 20:45:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887141#M544067</guid>
      <dc:creator>nickmayo</dc:creator>
      <dc:date>2016-07-25T20:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887142#M544068</link>
      <description>&lt;P&gt;Well you can make all the fields non-mandatory by using this in your client script. Let me know hoe it goes&lt;/P&gt;&lt;BR /&gt;&lt;P style="font-family: arial, sans-serif; color: #666666;"&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P style="font-family: arial, sans-serif; color: #666666;"&gt;Client script:&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14694807346319473" data-renderedposition="71_8_962_80" jivemacro_uid="_14694807346319473"&gt;&lt;P&gt;var allVariables = document.getElementById('variable_map').getElementsByTagName('item');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; for(var i = 0; i &amp;lt; allVariables.length; i++){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var item = allVariables[i];&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; g_form.setMandatory('variables.' + item.getAttribute('qname').toString(),false);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 21:05:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887142#M544068</guid>
      <dc:creator>Abhinay Erra</dc:creator>
      <dc:date>2016-07-25T21:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887143#M544069</link>
      <description>&lt;P&gt;Yes, I found that solution as well but that won't work. Take the following scenarios.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;On a task I have 5 variables. 3 are mandatory by UI policy, 2 are not. If I use that solution, it'll work by making all of them not mandatory. But as soon as my condition reverses, it will make all 5 mandatory, which makes two of the variables that do not need to be mandatory, mandatory. Does that make sense?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Sent from my Verizon, Samsung Galaxy smartphone&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 21:09:44 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887143#M544069</guid>
      <dc:creator>nickmayo</dc:creator>
      <dc:date>2016-07-25T21:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887144#M544070</link>
      <description>&lt;P&gt;I have not tried, but why would it make other two as mandatory? We are not using them in UI policy right?&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jul 2016 21:13:42 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887144#M544070</guid>
      <dc:creator>Abhinay Erra</dc:creator>
      <dc:date>2016-07-25T21:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887145#M544071</link>
      <description>&lt;P&gt;This &lt;/P&gt;&lt;BR /&gt;&lt;OL class="dp-c" start="1" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #5c5c5c; margin-bottom: 1px !important; margin-left: 45px !important;"&gt;&lt;LI&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;var&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; allVariables = document.getElementById(&lt;/SPAN&gt;&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;'variable_map').getElementsByTagName('item'&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;); &amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;grabs all variables regardless of state. &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;So this will work when setting them non-mandatory BUT when you go to set the variables BACK to mandatory, its going to set all variables to mandatory.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Jul 2016 14:03:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887145#M544071</guid>
      <dc:creator>nickmayo</dc:creator>
      <dc:date>2016-07-26T14:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get all variables on a task form via script</title>
      <link>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887146#M544072</link>
      <description>&lt;P&gt;I understand that part. How are you setting it to mandatory? I believe it is by using UI policies right? Then it will only set mandatory that 2 or 3 fields which you have in that UI policy.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Jul 2016 14:08:13 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-all-variables-on-a-task-form-via-script/m-p/1887146#M544072</guid>
      <dc:creator>Abhinay Erra</dc:creator>
      <dc:date>2016-07-26T14:08:13Z</dc:date>
    </item>
  </channel>
</rss>

