<?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>post Create your own (user) sys_id in Developer articles</title>
    <link>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/ta-p/2299146</link>
    <description>&lt;P&gt;&lt;A href="https://community.servicenow.com/community?id=community_blog&amp;amp;sys_id=14e51965db2200d013b5fb24399619fb" target="_self" rel="noopener noreferrer"&gt;&lt;STRONG&gt;Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="background-color: #fbf7bc; border: 2px solid #f0e000; width: 100%;"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="padding: 15px;"&gt;
&lt;P&gt;&lt;STRONG&gt;What is shared in this article, might not be best practice. Just sharing this to explore possibilities, find openings in ServiceNow, and have a mindset that your imagination is your limitation.&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just for fun this time, how to create your own (User) sys_id. I noticed there wasn't a Community article on this topic yet, so decided to write an article again.&lt;BR /&gt;&lt;EM&gt;Note: I just used sys_user as an example, though you could apply this in multiple places.&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Case&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;When creating new records, ServiceNow automatically&amp;nbsp;generates a unique sys_id. Though at some rare places in the system you'll notice there isn't actually a 32-character sys_id used but just a string. What the?!&lt;/P&gt;
&lt;P&gt;So could we do this ourselves? For example on a User record, with your own firstname.lastname or your nickname? Yes, you can!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;How to&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;You only have to apply &lt;STRONG&gt;setNewGuidValue&lt;/STRONG&gt;. Note this will only work for new records, not for updating records.&lt;BR /&gt;I also applied &lt;STRONG&gt;autoSysFields&lt;/STRONG&gt;. Just because I wanted to apply a custom Created date, so this would be my actual date of birth &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var gr = new GlideRecord('sys_user');
gr.initialize();
gr.setValue('user_name', 'mark.ragavan');
gr.setValue('first_name', 'Mark');
gr.setValue('last_name', 'Ragavan');
gr.setValue('sys_created_on', '1983-05-01 12:30:00');
gr.setNewGuidValue('mark.ragavan');
gr.autoSysFields();
gr.insert();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Result&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;A User record has been created with the above code. Have a look at the XML to verify that your custom sys_id has been applied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/148431i1B94833A1C236962/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;/P&gt;
&lt;P&gt;And that's actually it! So easy to apply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="height: 125px; width: 100%; background-color: #ccffcc; border: 2px solid #339966; padding: 15px;"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="lia-align-center" style="min-width: 100px; color: #339966; font-size: 4em; padding: 15px; border: 0px;"&gt;&lt;FONT face="wingdings,zapf dingbats"&gt;C&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="padding: 15px; padding-left: 0px; border: 0px;"&gt;
&lt;P&gt;If this content helped you, I would appreciate it if you hit &lt;STRONG&gt;bookmark&lt;/STRONG&gt;&amp;nbsp;or mark it as &lt;STRONG&gt;helpful&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- &lt;A href="https://community.servicenow.com/community?id=community_blog&amp;amp;sys_id=14e51965db2200d013b5fb24399619fb" target="_self"&gt;Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Mark Roethof&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;ServiceNow Technical Consultant&amp;nbsp;@ Paphos Group&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.linkedin.com/in/markroethof/" target="_blank" rel="noopener"&gt;LinkedIn&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jul 2024 08:07:20 GMT</pubDate>
    <dc:creator>Mark Roethof</dc:creator>
    <dc:date>2024-07-26T08:07:20Z</dc:date>
    <item>
      <title>Create your own (user) sys_id</title>
      <link>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/ta-p/2299146</link>
      <description>&lt;P&gt;&lt;A href="https://community.servicenow.com/community?id=community_blog&amp;amp;sys_id=14e51965db2200d013b5fb24399619fb" target="_self" rel="noopener noreferrer"&gt;&lt;STRONG&gt;Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="background-color: #fbf7bc; border: 2px solid #f0e000; width: 100%;"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="padding: 15px;"&gt;
&lt;P&gt;&lt;STRONG&gt;What is shared in this article, might not be best practice. Just sharing this to explore possibilities, find openings in ServiceNow, and have a mindset that your imagination is your limitation.&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just for fun this time, how to create your own (User) sys_id. I noticed there wasn't a Community article on this topic yet, so decided to write an article again.&lt;BR /&gt;&lt;EM&gt;Note: I just used sys_user as an example, though you could apply this in multiple places.&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Case&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;When creating new records, ServiceNow automatically&amp;nbsp;generates a unique sys_id. Though at some rare places in the system you'll notice there isn't actually a 32-character sys_id used but just a string. What the?!&lt;/P&gt;
&lt;P&gt;So could we do this ourselves? For example on a User record, with your own firstname.lastname or your nickname? Yes, you can!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;How to&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;You only have to apply &lt;STRONG&gt;setNewGuidValue&lt;/STRONG&gt;. Note this will only work for new records, not for updating records.&lt;BR /&gt;I also applied &lt;STRONG&gt;autoSysFields&lt;/STRONG&gt;. Just because I wanted to apply a custom Created date, so this would be my actual date of birth &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var gr = new GlideRecord('sys_user');
gr.initialize();
gr.setValue('user_name', 'mark.ragavan');
gr.setValue('first_name', 'Mark');
gr.setValue('last_name', 'Ragavan');
gr.setValue('sys_created_on', '1983-05-01 12:30:00');
gr.setNewGuidValue('mark.ragavan');
gr.autoSysFields();
gr.insert();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Result&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;A User record has been created with the above code. Have a look at the XML to verify that your custom sys_id has been applied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/148431i1B94833A1C236962/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;/P&gt;
&lt;P&gt;And that's actually it! So easy to apply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="height: 125px; width: 100%; background-color: #ccffcc; border: 2px solid #339966; padding: 15px;"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="lia-align-center" style="min-width: 100px; color: #339966; font-size: 4em; padding: 15px; border: 0px;"&gt;&lt;FONT face="wingdings,zapf dingbats"&gt;C&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="padding: 15px; padding-left: 0px; border: 0px;"&gt;
&lt;P&gt;If this content helped you, I would appreciate it if you hit &lt;STRONG&gt;bookmark&lt;/STRONG&gt;&amp;nbsp;or mark it as &lt;STRONG&gt;helpful&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- &lt;A href="https://community.servicenow.com/community?id=community_blog&amp;amp;sys_id=14e51965db2200d013b5fb24399619fb" target="_self"&gt;Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Mark Roethof&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;ServiceNow Technical Consultant&amp;nbsp;@ Paphos Group&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.linkedin.com/in/markroethof/" target="_blank" rel="noopener"&gt;LinkedIn&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 08:07:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/ta-p/2299146</guid>
      <dc:creator>Mark Roethof</dc:creator>
      <dc:date>2024-07-26T08:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create your own (user) sys_id</title>
      <link>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/tac-p/2299147#M538</link>
      <description>&lt;P&gt;This is stunning Mark.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for this information, it's very helpful &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 06:06:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/tac-p/2299147#M538</guid>
      <dc:creator>Omkar Mone</dc:creator>
      <dc:date>2019-07-22T06:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create your own (user) sys_id</title>
      <link>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/tac-p/2299148#M539</link>
      <description>&lt;P&gt;Awesome Mark &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 06:54:06 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/tac-p/2299148#M539</guid>
      <dc:creator>Harish KM</dc:creator>
      <dc:date>2019-07-22T06:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create your own (user) sys_id</title>
      <link>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/tac-p/2299151#M542</link>
      <description>&lt;P&gt;Is there a way to delete or update such record(CI) where sys_id is some other value.?&lt;BR /&gt;Not able to achieve same with fix script&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;var gr = new GlideRecord('cmdb_ci_win_server');&lt;BR /&gt;gr.addEncodedQuery('nameSTARTSWITHGabc');&lt;BR /&gt;gr.query();&lt;BR /&gt;gs.log(gr.getRowCount());&lt;BR /&gt;gs.log(gr.getDisplayName());&lt;BR /&gt;gs.log(gr.sys_id.toString()); // this is coming undefined&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;if (gr.next()) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; gs.log("Record is found to delete");&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; //gr.deleteRecord();&lt;BR /&gt;&amp;nbsp; gr.setNewGuidValue('c7a5d7fd873e4550e67dc8c80cbb35e3');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; gr.update();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; gr.setWorkflow(false);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; gr.autoSysFields(false);&lt;BR /&gt;}&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 14:23:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/tac-p/2299151#M542</guid>
      <dc:creator>PriyankaSadhwni</dc:creator>
      <dc:date>2022-07-29T14:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create your own (user) sys_id</title>
      <link>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/tac-p/2299152#M543</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;the &lt;A href="https://developer.servicenow.com/dev.do#!/reference/api/rome/server_legacy/c_GlideRecordAPI#r_GlideRecord-setNewGuidValue_String" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;setNewGuidValue&lt;/STRONG&gt;&lt;/A&gt; method appears to only be applicable when inserting a new record. It isn't used to overwrite what is already there.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Please mark reply as Helpful, if applicable. Thanks!&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 14:38:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/tac-p/2299152#M543</guid>
      <dc:creator>Allen Andreas</dc:creator>
      <dc:date>2022-07-29T14:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create your own (user) sys_id</title>
      <link>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/tac-p/2703781#M8074</link>
      <description>&lt;P&gt;It works perfectly in scoped applications also&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var guid = gs.generateGUID(); // this will generate a new id&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; hrCase = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;GlideRecord&lt;/SPAN&gt;&lt;SPAN&gt;('sn_hr_core_case');&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;hrCase.initialize();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;hrCase.setNewGuidValue(guid);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;---- set all other required fields.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; createdId = hrCase.insert();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;// createdId and guid both will be same&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Oct 2023 17:10:34 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/create-your-own-user-sys-id/tac-p/2703781#M8074</guid>
      <dc:creator>ShivarajG</dc:creator>
      <dc:date>2023-10-16T17:10:34Z</dc:date>
    </item>
  </channel>
</rss>

