<?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: How to pass check box value in widget in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787417#M444343</link>
    <description>&lt;P&gt;You can get the details from sys_id on server side.&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;//Client side
c.requested_for={
		displayValue: c.data.current_user.Name,
		value: c.data.current_user.ID,
		name: 'requested_for'
	};

c.data.user_id=c.requested_for.displayValue

//Html
&amp;lt;sn-record-picker ng-required="true" field="c.requested_for" sn-model='c.requested_for' 
                                table="'sys_user'" 
                                default-query="c.data.query" 
                                display-field="'name'" 
                                value-field="'sys_id'" 
                                search-fields="'name'" 
                                page-size="10" 
                                placeholder='Select User'&amp;gt;
              &amp;lt;/sn-record-picker&amp;gt;

// Server Side
if(input){
		if(input.user_id){
//your code
}
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 08 Aug 2021 13:19:30 GMT</pubDate>
    <dc:creator>Upender Kumar</dc:creator>
    <dc:date>2021-08-08T13:19:30Z</dc:date>
    <item>
      <title>How to pass check box value in widget</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787409#M444335</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;My requirement is I want to pass check box and Comments value to Server Side on clicking of button "Add" which is dynamic in widget -&lt;/P&gt;
&lt;P&gt;I am trying below code, however I am getting undefined value and check box selection is getting blank .&lt;/P&gt;
&lt;P&gt;I am beginner in widget designing . Can someone please help?&lt;/P&gt;
&lt;P&gt;Thanks in advance,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/203381i4BD4049076EC69A3/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I have written below code HTML Code -&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;div class="panel panel-default"&amp;gt;&lt;BR /&gt;&amp;lt;div class="panel-heading clearfix"&amp;gt;&lt;BR /&gt;&amp;lt;h3 class="panel-title pull-left"&amp;gt;&lt;BR /&gt;${Asset Certifications}&lt;BR /&gt;&amp;lt;/h3&amp;gt;&lt;BR /&gt; &amp;lt;/div&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;div&amp;gt;&lt;BR /&gt; &amp;lt;table class="table"&amp;gt;&lt;BR /&gt; &amp;lt;thead&amp;gt;&lt;BR /&gt; &amp;lt;tr&amp;gt;&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; &amp;lt;/tr&amp;gt;&lt;BR /&gt; &amp;lt;table&amp;gt;&lt;BR /&gt;&amp;lt;tr ng-repeat="alm in data.alms"&amp;gt;&lt;BR /&gt;&amp;lt;td&amp;gt;&lt;BR /&gt; {{alm.number }}&lt;BR /&gt;&amp;lt;input type='checkbox' checklist-model="test" checklist-value='' ng-click="selectedList(alm.sys_id)" /&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;label class="checkbox-inline"&amp;gt;&amp;lt;input type="checkbox" value=""&amp;gt;True&amp;lt;/label&amp;gt;&lt;BR /&gt;&amp;lt;label class="checkbox-inline"&amp;gt;&amp;lt;input type="checkbox" value=""&amp;gt;False&amp;lt;/label&amp;gt;&lt;BR /&gt;&amp;lt;label class="checkbox-inline"&amp;gt;&amp;lt;input type="checkbox" value=""&amp;gt;Comments&amp;lt;/label&amp;gt; &lt;BR /&gt;&amp;lt;/td&amp;gt;&lt;BR /&gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;BR /&gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;BR /&gt;&amp;lt;/tr&amp;gt;&lt;BR /&gt;&amp;lt;/table&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;div&amp;gt;&lt;BR /&gt;&amp;lt;input class="btn btn-primary btn-block" ng-click="c.addtoDashboard()" type="submit" value="Add"&amp;gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;BR /&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Client Script -&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;function($scope) {&lt;BR /&gt;/* widget controller */&lt;BR /&gt;var c = this;&lt;BR /&gt;var sect = []&lt;BR /&gt;c.addtoDashboard = function() {&lt;/P&gt;
&lt;P&gt;c.data.selected = $scope.selection;&lt;BR /&gt;c.server.update().then(function(){&lt;BR /&gt;c.data.selected = "";&lt;BR /&gt;})&lt;BR /&gt;}&lt;BR /&gt;$scope.data.selection= [];&lt;BR /&gt;$scope.selectedList = function (y) {&lt;BR /&gt;alert(y);&lt;BR /&gt;if (y) {&lt;BR /&gt;var index = $scope.data.selection.indexOf(y);&lt;BR /&gt;if (index === -1) {&lt;BR /&gt;$scope.data.selection.push(y);&lt;BR /&gt;}else{&lt;BR /&gt;$scope.data.selection.splice(index, 1);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Server Script -&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;(function() {&lt;BR /&gt;/* populate the 'data' object */&lt;BR /&gt;/* e.g., data.table = $sp.getValue('table'); */&lt;BR /&gt;data.alms = [];&lt;/P&gt;
&lt;P&gt;var gr= new GlideRecord('alm_hardware');&lt;BR /&gt; gr.addQuery("assigned_to", gs.getUserID());&lt;BR /&gt; &lt;BR /&gt; gr.query();&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;while(gr.next()){&lt;BR /&gt;var alm = {}&lt;BR /&gt;alm.number = gr.getDisplayValue('serial_number');&lt;BR /&gt;alm.short_description = gr.getDisplayValue('display_name');&lt;BR /&gt;alm.sys_id = gr.getUniqueValue('sys_id');&lt;BR /&gt;data.alms.push(alm);&lt;BR /&gt;}&lt;BR /&gt;//gs.addInfoMessage(input);&lt;BR /&gt;if(!input){&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;gs.addInfoMessage("return");&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;else{&lt;/P&gt;
&lt;P&gt;var selected_ids = input.selection;&lt;BR /&gt;gs.addInfoMessage(input.selected);&lt;/P&gt;
&lt;P&gt;}&lt;BR /&gt;})();&lt;/P&gt;</description>
      <pubDate>Sat, 07 Aug 2021 10:43:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787409#M444335</guid>
      <dc:creator>kambleneeta20</dc:creator>
      <dc:date>2021-08-07T10:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass check box value in widget</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787410#M444336</link>
      <description>&lt;P&gt;Try below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;&amp;lt;input type="checkbox" name="chkRow" ng-model="c.half_day"/&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;//Server side
if(input){
   gs.addInfoMessage(input.half_day);
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 Aug 2021 11:51:44 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787410#M444336</guid>
      <dc:creator>Upender Kumar</dc:creator>
      <dc:date>2021-08-07T11:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass check box value in widget</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787411#M444337</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;
&lt;P&gt;I am getting undefined error.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Aug 2021 17:03:06 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787411#M444337</guid>
      <dc:creator>kambleneeta20</dc:creator>
      <dc:date>2021-08-07T17:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass check box value in widget</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787412#M444338</link>
      <description>&lt;PRE class="language-markup"&gt;&lt;CODE&gt;&amp;lt;div&amp;gt;
&amp;lt;!-- your widget template --&amp;gt;
  &amp;lt;input type="checkbox" name="chkRow" ng-model="c.half_day"/&amp;gt;
  &amp;lt;input type="submit" value="Insert" ng-click="c.update()"&amp;gt;
&amp;lt;/div&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;api.controller=function() {
	/* widget controller */
	var c = this;
	c.half_day=false;
	c.update = function() {
		c.data.action = "Test";
		alert(c.half_day)
		c.data.half_day=c.half_day;
		c.server.update().then(function (response) {
			c.data = {};
		})
	}
};

//Server Side
(function() {
	/* populate the 'data' object */
	/* e.g., data.table = $sp.getValue('table'); */
	if(input.action == "Test"){

		gs.addInfoMessage(input.half_day);
	}
})();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 Aug 2021 17:23:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787412#M444338</guid>
      <dc:creator>Upender Kumar</dc:creator>
      <dc:date>2021-08-07T17:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass check box value in widget</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787413#M444339</link>
      <description>&lt;P&gt;Thank you it is working from above way which you have suggested.&lt;/P&gt;
&lt;P&gt;However is there any way to pass the sys_id of the record from client to Server , so accordingly record can be update.&lt;/P&gt;
&lt;P&gt;Thanks for your assistance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Aug 2021 18:06:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787413#M444339</guid>
      <dc:creator>kambleneeta20</dc:creator>
      <dc:date>2021-08-07T18:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass check box value in widget</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787414#M444340</link>
      <description>&lt;P&gt;You want to send sys_id from a reference field?&lt;/P&gt;</description>
      <pubDate>Sat, 07 Aug 2021 18:52:41 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787414#M444340</guid>
      <dc:creator>Upender Kumar</dc:creator>
      <dc:date>2021-08-07T18:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass check box value in widget</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787415#M444341</link>
      <description>&lt;P&gt;Please close the thread if it is resolved.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Aug 2021 20:43:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787415#M444341</guid>
      <dc:creator>Upender Kumar</dc:creator>
      <dc:date>2021-08-07T20:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass check box value in widget</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787416#M444342</link>
      <description>&lt;P&gt;I have done some changes and able to send the "sys_id".&lt;/P&gt;
&lt;P&gt;Now I also want to send text value to reference record in Server side.&lt;/P&gt;
&lt;P&gt;Can you please suggest ?&lt;/P&gt;</description>
      <pubDate>Sun, 08 Aug 2021 12:46:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787416#M444342</guid>
      <dc:creator>kambleneeta20</dc:creator>
      <dc:date>2021-08-08T12:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass check box value in widget</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787417#M444343</link>
      <description>&lt;P&gt;You can get the details from sys_id on server side.&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;//Client side
c.requested_for={
		displayValue: c.data.current_user.Name,
		value: c.data.current_user.ID,
		name: 'requested_for'
	};

c.data.user_id=c.requested_for.displayValue

//Html
&amp;lt;sn-record-picker ng-required="true" field="c.requested_for" sn-model='c.requested_for' 
                                table="'sys_user'" 
                                default-query="c.data.query" 
                                display-field="'name'" 
                                value-field="'sys_id'" 
                                search-fields="'name'" 
                                page-size="10" 
                                placeholder='Select User'&amp;gt;
              &amp;lt;/sn-record-picker&amp;gt;

// Server Side
if(input){
		if(input.user_id){
//your code
}
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Aug 2021 13:19:30 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-pass-check-box-value-in-widget/m-p/1787417#M444343</guid>
      <dc:creator>Upender Kumar</dc:creator>
      <dc:date>2021-08-08T13:19:30Z</dc:date>
    </item>
  </channel>
</rss>

