{"id":1554,"date":"2018-03-16T10:13:54","date_gmt":"2018-03-16T09:13:54","guid":{"rendered":"https:\/\/help.cirrus-shield.com\/docs\/developer-guide\/javascript-library\/create-record\/"},"modified":"2024-09-11T14:49:02","modified_gmt":"2024-09-11T13:49:02","slug":"create-record","status":"publish","type":"docs","link":"https:\/\/help.cirrus-shield.com\/en\/docs\/developer-guide\/javascript-library\/create-record\/","title":{"rendered":"Create Record"},"content":{"rendered":"<section class=\"fw-main-row \">\n<div class=\"fw-container\">\n<div class=\"fw-row\">\n<div class=\"fw-col-xs-12\">\n<p>This function is used to create a new record and it returns the GUID of the newly created one and a message info.<\/p>\n<ul>\n<li><strong><u>Function<\/u><\/strong><u>:<\/u> CreateRecord(&lt;Object Name&gt;, &lt;Matching Field&gt;, &lt;XML Data&gt;, &lt;use ExternalID&gt;, &lt;Asynchronous Update&gt;)\n<ul>\n<li><span style=\"color: #0000ff;\">var<\/span> ObjResult = CreateRecord(&lt;Object Name&gt;, &lt;Matching Field&gt;, &lt;XML Data&gt;, &lt;use ExternalID&gt;, &lt;Asynchronous Update&gt;);<\/li>\n<li><span style=\"color: #0000ff;\">var<\/span> NewRecordGUID = ObjResult.RecordGUID;<\/li>\n<li><span style=\"color: #0000ff;\">var<\/span> message = msgInfo;<\/li>\n<li>Use External Id: if the value is <strong>false<\/strong>, then you must send the GUID of the lookup fields in the XML data otherwise send the external Id value. Also if the parameter <strong>useExternalID<\/strong> is not existing in the function parameters, then it will considered as it is set to <strong>true<\/strong>.<\/li>\n<li>Asynchronous Update: This parameter is optional and has a default value of <strong>true<\/strong>. It triggers the calculation of sharing rules on the record asynchronously. When the API call is part of a series of dependent actions or when we need to immediately display the updated record to the user, it is advisable to set this parameter to <strong>false<\/strong>. The <strong>false<\/strong> value will indicate to Cirrus Shield that the sharing rules on the record should be calculated synchronously.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p style=\"padding-left: 30px;\"><u>XML Data Format:<\/u><\/p>\n<pre><span style=\"color: #ff0000;\">&lt;Data&gt;<\/span>\n<span style=\"color: #ff0000;\">&lt;Object Name&gt;<\/span>\n<span style=\"color: #ff0000;\">&lt;Matching Field Name&gt;<\/span>\n\nValue\n\n<span style=\"color: #ff0000;\">&lt;\/Matching Field Name&gt;<\/span>\n<span style=\"color: #ff0000;\">&lt;Field Name&gt;<\/span>\n\nValue\n\n<span style=\"color: #ff0000;\">&lt;\/Field Name&gt;<\/span>\n<span style=\"color: #ff0000;\">&lt;Field Name&gt;<\/span>\n\nValue\n\n<span style=\"color: #ff0000;\">&lt;\/Field Name&gt;<\/span>\n<span style=\"color: #ff0000;\">&lt;\/Object Name&gt;<\/span>\n<span style=\"color: #ff0000;\">&lt;\/Data&gt;<\/span>\n<\/pre>\n<ul>\n<li><strong><u>Usage<\/u><u>:\u00a0<\/u><\/strong><span style=\"color: #0000ff;\">var<\/span> objTask = GetDataByID(GetRecordGUID(),<span style=\"color: #ff0000;\">&#8220;Task&#8221;, &#8220;Id,Name,Start,End,Description,Location,Attendees,OwnerId,IsDeleted&#8221;<\/span>);<\/li>\n<\/ul>\n<pre><span style=\"color: #0000ff;\">var<\/span> offset = GetTimeZone();\n<span style=\"color: #0000ff;\">var<\/span> xmlStr = <span style=\"color: #ff0000;\">&lt;Data&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;Task&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;Name&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">Client Meeting<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;\/Name&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;Start&gt;<\/span>;\nxmlStr += objTask.Start + offset;\nxmlStr += <span style=\"color: #ff0000;\">&lt;\/Start&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;End&gt;<\/span>;\nxmlStr += objTask.End + offset;\nxmlStr += <span style=\"color: #ff0000;\">&lt;\/End&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;Description&gt;<\/span>;\nxmlStr += objTask.Description;\nxmlStr += <span style=\"color: #ff0000;\">&lt;\/Description&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;Location&gt;<\/span>;\nxmlStr += objTask.Location;\nxmlStr += <span style=\"color: #ff0000;\">&lt;\/Location<\/span>;\nxmlStr +=<span style=\"color: #ff0000;\"> &lt;Attendees&gt;<\/span>;\nxmlStr += objTask.Attendees;\nxmlStr += <span style=\"color: #ff0000;\">&lt;\/Attendees&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;OwnerId&gt;<\/span>;\nxmlStr += objTask.OwnerId;\nxmlStr += <span style=\"color: #ff0000;\">&lt;\/OwnerId&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;IsDeleted&gt;<\/span>;\nxmlStr += 0;\nxmlStr +=<span style=\"color: #ff0000;\"> &lt;\/IsDeleted&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;\/Task&gt;<\/span>;\nxmlStr += <span style=\"color: #ff0000;\">&lt;\/Data&gt;<\/span>;\n\n<span style=\"background-color: #ffff66;\"><span style=\"color: #0000ff;\">var<\/span>\u00a0ObjResult = CreateRecord(<span style=\"color: #ff0000;\">\"Task\"<\/span>,<span style=\"color: #ff0000;\"> \"Id\"<\/span>, xmlStr, false, true);<\/span>\n<span style=\"color: #0000ff;\">var<\/span> TaskGUID \u00a0= ObjResult.RecordGUID;\n<span style=\"color: #0000ff;\">var<\/span> message = ObjResult.msgInfo;\n<\/pre>\n<ul>\n<li><strong><u>Output<\/u><\/strong><u>:<\/u>\n<ul>\n<li><span style=\"color: #ff6600;\"><strong><u>Success<\/u><\/strong><\/span><u><span style=\"color: #ff6600;\">:<\/span><br \/><\/u>The following message will be displayed<span style=\"color: #ff0000;\"> \u201cNew record is created successfully.\u201d<\/span><br \/>It will return the GUID of the newly created record.<\/li>\n<li><span style=\"color: #ff6600;\"><strong><u>Failure<\/u><\/strong><\/span><u><span style=\"color: #ff6600;\">:<\/span><br \/><\/u>An error message will be displayed.<br \/>The GUID will be null.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/section>\n<p><!-- 140339e0358900d73fc95fe318f34cc7 --><\/p>\n\n\n<p><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":945,"menu_order":12,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_tag":[],"class_list":["post-1554","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/docs\/1554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/comments?post=1554"}],"version-history":[{"count":6,"href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/docs\/1554\/revisions"}],"predecessor-version":[{"id":10314,"href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/docs\/1554\/revisions\/10314"}],"up":[{"embeddable":true,"href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/docs\/945"}],"next":[{"title":"Update Record","link":"https:\/\/help.cirrus-shield.com\/en\/docs\/developer-guide\/javascript-library\/update-record\/","href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/docs\/1555"}],"prev":[{"title":"Get Data By Column","link":"https:\/\/help.cirrus-shield.com\/en\/docs\/developer-guide\/javascript-library\/get-data-by-column\/","href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/docs\/1553"}],"wp:attachment":[{"href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/media?parent=1554"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/help.cirrus-shield.com\/en\/wp-json\/wp\/v2\/doc_tag?post=1554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}