<?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: Item Details fields with default or required values are always empty when created via scripting in Fusion Manage Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-manage-forum/item-details-fields-with-default-or-required-values-are-always/m-p/11569982#M610</link>
    <description>&lt;P&gt;Yes, you guess correct. Google for "prepareRequest" on this forum, and you will find the example library.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can do a lot in 9 seconds, eg whereused lookup call, or similar, but yes calling APIs from scripts should be a "last resort" option imho. If your solution uses this extensively, my guess is that you are building yourself trouble for the future, and I imagine Autodesk would likely not be sympathetic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Queries are one thing, but changing data is a bad idea (it will be in a different transaction), and trying to change the actual data that is passed into the scripting session will simply not work. Remember your changes made during scripting are not saved to the database until your script completes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But as a test-bed to play with the APIs before deploying them to proper middleware, or a proper Rest client, then I think would be ok.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Personally I would like Autodesk to extend the javascript API to allow search queries, where-used, markups, attachments etc to be possible, which will reduce the need for javascript calling v3 API. Having an extra boolan argument to createItem() method, to say "Yes I want to initialise with the defaults", would be a great start.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Nov 2022 13:12:19 GMT</pubDate>
    <dc:creator>philipfrench</dc:creator>
    <dc:date>2022-11-22T13:12:19Z</dc:date>
    <item>
      <title>Item Details fields with default or required values are always empty when created via scripting</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/item-details-fields-with-default-or-required-values-are-always/m-p/11566871#M607</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is it an expected behavior in PLM that when an item is created via scripting&amp;nbsp; ( createItem("WS_XYZ") ) fields with default or required values stay empty?&lt;/P&gt;&lt;P&gt;For example if you have a field with priority LOW/MED/HIGH and you set the default to MED, the field will have an empty value when it is created from a script.&lt;/P&gt;&lt;P&gt;Also when you set up a field to be required, creating a record via script will not give a warning or error, that there are missing values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right, now you need very deep knowledge of the workspace configuration, to avoid this in scripting.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 10:26:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/item-details-fields-with-default-or-required-values-are-always/m-p/11566871#M607</guid>
      <dc:creator>patrick.fluegge</dc:creator>
      <dc:date>2022-11-21T10:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Item Details fields with default or required values are always empty when created via scripting</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/item-details-fields-with-default-or-required-values-are-always/m-p/11567878#M608</link>
      <description>&lt;P&gt;Yes, it is expected/known. Whether that is what you want, or not, is another question, but the javascript engine does not respect default values, nor permissions. (The Rest API follows different rules).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can set the field values automatically via making a script call to /api/v3/workspace/&amp;lt;WS&amp;gt;/fields, and then parse the results, extract the default values, and set them onto a new item.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See script example below. Look at the output of this API call first in the browser, then the example will hopefully make sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Making an API lookup like this for every create is poor performance. I would not deploy it in this form myself, but it is a minimal example - albeit nasty looking code. You may be able to take something from the example.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pic2.jpg" style="width: 660px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1142458i4747F7ABED02182E/image-size/large?v=v2&amp;amp;px=999" role="button" title="pic2.jpg" alt="pic2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Try the api call in the browser and inspect the response for "defaultValue"...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pic1.jpg" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1142460iBE53F5A6FCA9514A/image-size/large?v=v2&amp;amp;px=999" role="button" title="pic1.jpg" alt="pic1.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pic3.jpg" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1142459iAB61235174275157/image-size/large?v=v2&amp;amp;px=999" role="button" title="pic3.jpg" alt="pic3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 17:29:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/item-details-fields-with-default-or-required-values-are-always/m-p/11567878#M608</guid>
      <dc:creator>philipfrench</dc:creator>
      <dc:date>2022-11-21T17:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: Item Details fields with default or required values are always empty when created via scripting</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/item-details-fields-with-default-or-required-values-are-always/m-p/11569785#M609</link>
      <description>&lt;P&gt;Hello Philip,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for the confirmation.&lt;/P&gt;&lt;P&gt;I'm assuming you are using some other functions to make that GET request? The function "prepareReq()" in line 13 probably contains calls to the 2-legged OAuth and extracts bearer token etc. ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Considering the limited script runtime of 9 sec., this will probably cause a lot more issues with timeouts. Still interesting though, that we can use such advanced function inside "Actions Scripts".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 11:43:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/item-details-fields-with-default-or-required-values-are-always/m-p/11569785#M609</guid>
      <dc:creator>patrick.fluegge</dc:creator>
      <dc:date>2022-11-22T11:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: Item Details fields with default or required values are always empty when created via scripting</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/item-details-fields-with-default-or-required-values-are-always/m-p/11569982#M610</link>
      <description>&lt;P&gt;Yes, you guess correct. Google for "prepareRequest" on this forum, and you will find the example library.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can do a lot in 9 seconds, eg whereused lookup call, or similar, but yes calling APIs from scripts should be a "last resort" option imho. If your solution uses this extensively, my guess is that you are building yourself trouble for the future, and I imagine Autodesk would likely not be sympathetic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Queries are one thing, but changing data is a bad idea (it will be in a different transaction), and trying to change the actual data that is passed into the scripting session will simply not work. Remember your changes made during scripting are not saved to the database until your script completes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But as a test-bed to play with the APIs before deploying them to proper middleware, or a proper Rest client, then I think would be ok.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Personally I would like Autodesk to extend the javascript API to allow search queries, where-used, markups, attachments etc to be possible, which will reduce the need for javascript calling v3 API. Having an extra boolan argument to createItem() method, to say "Yes I want to initialise with the defaults", would be a great start.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 13:12:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/item-details-fields-with-default-or-required-values-are-always/m-p/11569982#M610</guid>
      <dc:creator>philipfrench</dc:creator>
      <dc:date>2022-11-22T13:12:19Z</dc:date>
    </item>
  </channel>
</rss>

