<?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 Re: I want to map Question- Answer tables value with custom table fields  in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714219#M371145</link>
    <description>&lt;P&gt;&lt;SN-MENTION class="sn-mention" table="live_profile" sysid="7c03aa76db960010d82ffb24399619c7"&gt;@Supriya Waghmode&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No need to query the question_answer table&lt;/P&gt;
&lt;P&gt;You can do it directly like this&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function executeRule(current, previous /*null when async*/) {

	// Add your code here

	var arr = [];
	var variables = current.variables.getElements();
	for (var i=0;i&amp;lt;variables.length;i++) {
		var question = variables[i].getQuestion();
		var label = question.getLabel();
		var value = question.getDisplayValue();
		if(label != '' &amp;amp;&amp;amp; value != ''){
			var obj = {};
			obj[label] = value.toString();
			arr.push(obj);
		}
	}

	gs.info(JSON.stringify(arr));

})(current, previous);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
    <pubDate>Tue, 09 Feb 2021 08:50:22 GMT</pubDate>
    <dc:creator>Ankur Bawiskar</dc:creator>
    <dc:date>2021-02-09T08:50:22Z</dc:date>
    <item>
      <title>I want to map Question- Answer tables value with custom table fields</title>
      <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714217#M371143</link>
      <description>&lt;P&gt;Requirement : I want to add the record producers variables to custom table(business case).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Approach : 1.Created a BR on insert -request&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2. getting variables values from Question answer tables&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Question: How to map name: value pair with custom tables fields ?&lt;/P&gt;
&lt;P&gt;Below script: i have written to get&amp;nbsp; &amp;nbsp;variables values&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; var jsonObj = {};&lt;BR /&gt; var arr = [];&lt;BR /&gt; var obj = {};&lt;BR /&gt; var incRec = new GlideRecord('question_answer');&lt;BR /&gt; incRec.addQuery('table_sys_id', current.sys_id);&lt;BR /&gt; incRec.query();&lt;BR /&gt; while (incRec.next()) {&lt;BR /&gt; var variableValue = incRec.value;&lt;BR /&gt; var variableLabel = incRec.question.getDisplayValue();&lt;BR /&gt; obj[variableLabel] = variableValue.toString();&lt;BR /&gt; }&lt;BR /&gt; arr.push(obj);&lt;BR /&gt; jsonObj.Variables = arr;&lt;BR /&gt; gs.info(JSON.stringify(jsonObj));&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 07:52:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714217#M371143</guid>
      <dc:creator>Supriya Waghmod</dc:creator>
      <dc:date>2021-02-09T07:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: I want to map Question- Answer tables value with custom table fields</title>
      <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714218#M371144</link>
      <description>&lt;P&gt;You would like to map those values to another custom table other than the Record producer target table?&lt;/P&gt;
&lt;P&gt;If yes then you can use the script section in Record producer, Glide to custom table map your record producer values to that custom table.&lt;/P&gt;
&lt;P&gt;Sample Script:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var custom = new GlideRecord('custom_table');
custom.intialize();
custom.field_name1 = producer.variable-name1;
custom.insert();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Please mark my answer as helpful/correct, if applicable.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Sai Kumar&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 08:38:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714218#M371144</guid>
      <dc:creator>Sai Kumar B</dc:creator>
      <dc:date>2021-02-09T08:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: I want to map Question- Answer tables value with custom table fields</title>
      <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714219#M371145</link>
      <description>&lt;P&gt;&lt;SN-MENTION class="sn-mention" table="live_profile" sysid="7c03aa76db960010d82ffb24399619c7"&gt;@Supriya Waghmode&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No need to query the question_answer table&lt;/P&gt;
&lt;P&gt;You can do it directly like this&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function executeRule(current, previous /*null when async*/) {

	// Add your code here

	var arr = [];
	var variables = current.variables.getElements();
	for (var i=0;i&amp;lt;variables.length;i++) {
		var question = variables[i].getQuestion();
		var label = question.getLabel();
		var value = question.getDisplayValue();
		if(label != '' &amp;amp;&amp;amp; value != ''){
			var obj = {};
			obj[label] = value.toString();
			arr.push(obj);
		}
	}

	gs.info(JSON.stringify(arr));

})(current, previous);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 08:50:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714219#M371145</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2021-02-09T08:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: I want to map Question- Answer tables value with custom table fields</title>
      <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714220#M371146</link>
      <description>&lt;P&gt;1.How can I send the request number through this??&lt;/P&gt;
&lt;P&gt;2.multiple values of array - to add one field&lt;/P&gt;
&lt;P&gt;if(producer.aua==true){&lt;BR /&gt; arr.push("AUA").toStrin();&lt;BR /&gt;}&lt;BR /&gt;if(producer.eur==true){&lt;BR /&gt; arr.push("EUR").toString();&lt;BR /&gt;}&lt;BR /&gt;if(producer.soa==true){&lt;BR /&gt; arr.push("SOA").toString();&lt;BR /&gt;}&lt;BR /&gt;if(producer.noa==true){&lt;BR /&gt; arr.push("NOA").toString();&lt;BR /&gt;} &lt;BR /&gt;gs.log("TEST-SW"+arr);&lt;/P&gt;
&lt;P&gt;need set att custome table field&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 10:32:27 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714220#M371146</guid>
      <dc:creator>Supriya Waghmod</dc:creator>
      <dc:date>2021-02-09T10:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: I want to map Question- Answer tables value with custom table fields</title>
      <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714221#M371147</link>
      <description>&lt;P&gt;&lt;SN-MENTION class="sn-mention" table="live_profile" sysid="7c03aa76db960010d82ffb24399619c7"&gt;@Supriya Waghmode&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you get a chance to check the script I shared?&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 11:14:06 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714221#M371147</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2021-02-09T11:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: I want to map Question- Answer tables value with custom table fields</title>
      <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714222#M371148</link>
      <description>&lt;P&gt;Thanks for reply.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ankur I am trying another&amp;nbsp; approach- scripting through producer&lt;/P&gt;
&lt;P&gt;currently stuck @&lt;/P&gt;
&lt;P&gt;1.How can I send the request number through this??&lt;/P&gt;
&lt;P&gt;2.multiple values of array - to add one field&lt;/P&gt;
&lt;P&gt;if(producer.aua==true){&lt;BR /&gt;arr.push("AUA").toString();&lt;BR /&gt;}&lt;BR /&gt;if(producer.eur==true){&lt;BR /&gt;arr.push("EUR").toString();&lt;BR /&gt;}&lt;BR /&gt;if(producer.soa==true){&lt;BR /&gt;arr.push("SOA").toString();&lt;BR /&gt;}&lt;BR /&gt;if(producer.noa==true){&lt;BR /&gt;arr.push("NOA").toString();&lt;BR /&gt;}&lt;BR /&gt;gs.log("TEST-SW"+arr);&lt;/P&gt;
&lt;P&gt;need set att custome table field&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 11:20:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714222#M371148</guid>
      <dc:creator>Supriya Waghmod</dc:creator>
      <dc:date>2021-02-09T11:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: I want to map Question- Answer tables value with custom table fields</title>
      <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714223#M371149</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;you are referring to record producer then it won't have any Request number&lt;/P&gt;
&lt;P&gt;Can you explain your business use-case&lt;/P&gt;
&lt;P&gt;I have already shared script on how to generate the JSON array of objects for the variables&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 12:04:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714223#M371149</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2021-02-09T12:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: I want to map Question- Answer tables value with custom table fields</title>
      <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714224#M371150</link>
      <description>&lt;P&gt;&lt;SN-MENTION class="sn-mention" table="live_profile" sysid="7c03aa76db960010d82ffb24399619c7"&gt;@Supriya Waghmode&lt;/SN-MENTION&gt;&amp;nbsp;In Record producer post insert script you send number via current.number(current table request number), you have to use post insert script because number will be generated in target table upon insertion of the record.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 17:49:44 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/1714224#M371150</guid>
      <dc:creator>Sai Kumar B</dc:creator>
      <dc:date>2021-02-09T17:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: I want to map Question- Answer tables value with custom table fields</title>
      <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/2464127#M962120</link>
      <description>&lt;P&gt;Hello Ankur,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the code. It was indeed helpful. I want to ask one additional request in this if you could help me. If I want to make each Label and Value in new line then how can I do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anirban&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 17:59:04 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/2464127#M962120</guid>
      <dc:creator>anirban300</dc:creator>
      <dc:date>2023-01-31T17:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: I want to map Question- Answer tables value with custom table fields</title>
      <link>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/2464456#M962259</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/399168"&gt;@anirban300&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can join the array with new line i.e. \n while setting the value in some field&lt;/P&gt;
&lt;P&gt;but remember that field should support new line character&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 03:06:04 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/i-want-to-map-question-answer-tables-value-with-custom-table/m-p/2464456#M962259</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2023-02-01T03:06:04Z</dc:date>
    </item>
  </channel>
</rss>

