<?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>topic Re: Can't save a webmap with code from sandbox example in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1323004#M82089</link>
    <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully I understand your question right. To save a webmap to your portal you must specify the portal url on your portal item before calling webmap.saveAs as shown below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const item = {
   title: title.value,
   portal: {
     url: "url-to-your-portal"
   }
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Aug 2023 15:31:05 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2023-08-28T15:31:05Z</dc:date>
    <item>
      <title>Can't save a webmap with code from sandbox example using seperate custom Javascript file</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1322726#M82083</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to save a webmap to my portal but I get the error below when trying to save it.&lt;/P&gt;&lt;P&gt;Error: The item does not exist yet and cannot be updated&lt;/P&gt;&lt;P&gt;I've tried both the update and save new code and neither works.&amp;nbsp; My sample code is below.&lt;/P&gt;&lt;P&gt;I have tried both a dynamic and hard coded link.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// item automatically casts to a PortalItem instance by saveAs&lt;BR /&gt;const l_title = document.getElementById("webMapTitle");&lt;BR /&gt;const item = {&lt;BR /&gt;title: l_title.value&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;//// Setting authMode to immediate signs the user in once loaded&lt;BR /&gt;//portal = new Portal();&lt;BR /&gt;//portal.authMode = "immediate";&lt;BR /&gt;//// Auto should sign you in automatically&lt;BR /&gt;//portal.authMode = "auto";&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Update properties of the WebMap related to the view.&lt;BR /&gt;// This should be called just before saving a webmap.&lt;BR /&gt;//portal.load().then(function () {&lt;BR /&gt;map.updateFrom(view).then(() =&amp;gt; {&lt;BR /&gt;map.saveAs(item)&lt;BR /&gt;// Saved successfully&lt;BR /&gt;.then((item) =&amp;gt; {&lt;BR /&gt;// link to the newly-created web scene item&lt;BR /&gt;const itemPageUrl = `${item.portal.url}/home/item.html?id=${item.id}`; //OG itemPageURL setting&lt;BR /&gt;//const itemPageUrl = "&lt;A href="https://www.arcgis.com/home/item.html?id=a24a038265eb4f3584451292c70d68ad" target="_blank" rel="noopener"&gt;https://www.arcgis.com/home/item.html?id=a24a038265eb4f3584451292c70d68ad&lt;/A&gt;"&amp;nbsp;&lt;BR /&gt;const link = `&amp;lt;a target="_blank" href="${itemPageUrl}"&amp;gt;${l_title.value}&amp;lt;/a&amp;gt;`;&lt;/P&gt;&lt;P&gt;alert("Successfully saved as &amp;lt;i&amp;gt;${link}&amp;lt;/i&amp;gt;");&lt;BR /&gt;})&lt;BR /&gt;// Save didn't work correctly&lt;BR /&gt;.catch((error) =&amp;gt; {&lt;BR /&gt;if (error.name != "identity-manager:user-aborted") {&lt;BR /&gt;alert("Error: " + error.message);&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've also tried the to save using a portal also&lt;/P&gt;&lt;P&gt;////Save a new Webmap&lt;BR /&gt;portal.load().then(() =&amp;gt; {&lt;BR /&gt;&amp;nbsp;map.updateFrom(view).then(() =&amp;gt; {&lt;BR /&gt;&amp;nbsp;map.saveAs({&lt;BR /&gt;&amp;nbsp;title: l_title,&lt;BR /&gt;&amp;nbsp;portal: portal&lt;BR /&gt;&amp;nbsp;});&lt;BR /&gt;&amp;nbsp;});&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone provide a working example of how to save to one's portal or get the portal to queue a log in window for me to authenticate?&amp;nbsp; It works when I query portal items, but now when I try to save maps.&amp;nbsp; The sanbox works on the ESRI server, but not in my local code.&lt;/P&gt;&lt;P&gt;Any help is appreciated, thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 15:45:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1322726#M82083</guid>
      <dc:creator>dtstopper</dc:creator>
      <dc:date>2023-09-01T15:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can't save a webmap with code from sandbox example</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1323004#M82089</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully I understand your question right. To save a webmap to your portal you must specify the portal url on your portal item before calling webmap.saveAs as shown below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const item = {
   title: title.value,
   portal: {
     url: "url-to-your-portal"
   }
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 15:31:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1323004#M82089</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-08-28T15:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Can't save a webmap with code from sandbox example</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1323900#M82110</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've tried 2 different portal URLs and both give me the same error.&lt;/P&gt;&lt;P&gt;Error: The item does not exist yet and cannot be updated&lt;/P&gt;&lt;P&gt;I've tried both URLs below with no luck.&amp;nbsp; I tried them seperately, but listed them both below to show what I'm using.&lt;/P&gt;&lt;P&gt;const itemPageUrl = &lt;A href="https://sbcounty.maps.arcgis.com/" target="_blank" rel="noopener"&gt;https://sbcounty.maps.arcgis.com/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;const itemPageUrl = &lt;A href="https://www.arcgis.com/" target="_blank" rel="noopener"&gt;https://www.arcgis.com/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;// item automatically casts to a PortalItem instance by saveAs&lt;BR /&gt;const l_title = document.getElementById("webMapTitle");&lt;BR /&gt;const item = {&lt;BR /&gt;title: l_title.value,&lt;BR /&gt;portal: {&lt;BR /&gt;url: itemPageUrl&lt;BR /&gt;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;Do you have an example of a proper URL setting?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I'm trying to use an authMode of "immediate" so it prompts me for my credentials, but that isn't happening.&amp;nbsp;&lt;/P&gt;&lt;P&gt;portal = new Portal();&lt;BR /&gt;portal.authMode = "immediate";&lt;/P&gt;&lt;P&gt;I just get the immediate error above.&lt;/P&gt;&lt;P&gt;I'm trying to save a new map to my profile as well as update an existing map I made from before.&amp;nbsp; Both examples don't work for me.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 15:26:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1323900#M82110</guid>
      <dc:creator>dtstopper</dc:creator>
      <dc:date>2023-08-30T15:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can't save a webmap with code from sandbox example</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1324791#M82135</link>
      <description>&lt;P&gt;After further investigation, I found that the map and view objects I constructed are fine.&amp;nbsp; However, when the objects are being passed to my javascript code (in a seperate JS file) the objects are empty as opposed to running javscript inline with the HTML.&amp;nbsp; The sandbox example works perfectly when I copy and paste it into an html file, however I want to make it more dynamic by assembling the save functionality after a custom map has been rendered.&amp;nbsp; I will continue to look and figure out why it matters when you put this code in a JS file versus inline with HTML.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 15:44:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1324791#M82135</guid>
      <dc:creator>dtstopper</dc:creator>
      <dc:date>2023-09-01T15:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can't save a webmap with code from sandbox example using seperate custom Javascript file</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1325558#M82150</link>
      <description>&lt;P&gt;There was no issue with the code, it turns out that when you assign an API Key to your code when trying to save a map it will not work and give you a misleading error message saying the item doesn't exist.&amp;nbsp; If you are using an API Key from ESRI in your code, remove it from your map creation and saving code.&amp;nbsp; This resolved it for me, hope this helps someone else.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 18:52:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-save-a-webmap-with-code-from-sandbox-example/m-p/1325558#M82150</guid>
      <dc:creator>dtstopper</dc:creator>
      <dc:date>2023-09-05T18:52:41Z</dc:date>
    </item>
  </channel>
</rss>

