<?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: How to access field IDs by looping in Fusion Manage Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10269582#M1132</link>
    <description>Awesome, thank you!</description>
    <pubDate>Mon, 26 Apr 2021 18:16:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-04-26T18:16:56Z</dc:date>
    <item>
      <title>How to access field IDs by looping</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10269340#M1130</link>
      <description>&lt;P&gt;I'm trying to clear a large number of fields. What is the proper syntax to create a loop so I don't have to individually type each field ID?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Example:&lt;/P&gt;&lt;P&gt;item.B1_NOTIFICATION_1 = null;&lt;/P&gt;&lt;P&gt;item.B1_NOTIFICATION_2 = null;&lt;/P&gt;&lt;P&gt;item.B1_NOTIFICATION_3 = null;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;item.B2_NOTIFICATION_1 = null;&lt;/P&gt;&lt;P&gt;item.B2_NOTIFICATION_2 = null;&lt;/P&gt;&lt;P&gt;item.B2_NOTIFICATION_3 = null;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would want to create a loop where I replace the number.&lt;/P&gt;&lt;P&gt;for (var i=1; i&amp;lt;=10; i++){&lt;/P&gt;&lt;P&gt;&amp;nbsp; item.B1_NOTIFICATION_[i] = null;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 16:49:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10269340#M1130</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-26T16:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to access field IDs by looping</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10269405#M1131</link>
      <description>&lt;P&gt;Try one of these. The first is a double loop to build up your field name.&lt;/P&gt;&lt;P&gt;The second is to loop through every field in the item, and test whether that field id contains a string eg _NOTIFICATION_.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which approach is best depends on whether you have other fields containing _NOTIFICATION_ that you don't want to set to null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF you find there are excessive entries in your Change Log (things being set to null when they are already null), then wrap your setting to null, with something like this:&lt;/P&gt;&lt;P&gt;if (item[f]!==null &amp;amp;&amp;amp; f.indexOf('_NOTIFICATION_')&amp;gt;0) item[f]=null; // only set to null if not already null.&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="p3.png" style="width: 653px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/911799i45A92B37A45E2F4D/image-size/large?v=v2&amp;amp;px=999" role="button" title="p3.png" alt="p3.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 17:10:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10269405#M1131</guid>
      <dc:creator>philipfrench</dc:creator>
      <dc:date>2021-04-26T17:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to access field IDs by looping</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10269582#M1132</link>
      <description>Awesome, thank you!</description>
      <pubDate>Mon, 26 Apr 2021 18:16:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10269582#M1132</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-26T18:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to access field IDs by looping</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10275806#M1133</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;Is it possible to do the same to access items from another workspace? And for creating variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have something like:&lt;/P&gt;&lt;P&gt;var SUP1 = item.SUP1_SUPPLIER_1;&amp;nbsp; // Link to 1st item in another workspace&lt;/P&gt;&lt;P&gt;var SUP2 = item.SUP2_SUPPLIER_1;&amp;nbsp; // Link to 2nd item&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUP1.TOOL_COST_1&lt;/P&gt;&lt;P&gt;SUP1.TOOL_COST_2&lt;/P&gt;&lt;P&gt;SUP1.TOOL_COST_3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUP2.TOOL_COST_1&lt;/P&gt;&lt;P&gt;SUP2.TOOL_COST_2&lt;/P&gt;&lt;P&gt;SUP2.TOOL_COST_3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wasn't sure how to do the variable, so I tried&amp;nbsp;&amp;nbsp;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;item['SUP'+i]['TOOL_COST_'+j]&amp;nbsp;&lt;/STRONG&gt;&lt;FONT color="#000000"&gt;But that didn't work&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 16:26:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10275806#M1133</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-28T16:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to access field IDs by looping</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10277493#M1134</link>
      <description>&lt;P&gt;Yes, this also works when accessing items of other workspaces - this should work to set the first value of the first supplier:&lt;/P&gt;
&lt;P&gt;item['&lt;SPAN&gt;SUP' + i + '_SUPPLIER_1'&lt;/SPAN&gt;]['TOOL_COST_' + j]&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 07:02:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10277493#M1134</guid>
      <dc:creator>sven.dickmans</dc:creator>
      <dc:date>2021-04-29T07:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to access field IDs by looping</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10277644#M1135</link>
      <description>&lt;P&gt;As Sven says, you can indeed refer to the other item, and read/write properties from it.&lt;/P&gt;&lt;P&gt;Each item is treated as an associative array (=map, hashtable, dictionary... in other languages).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not exactly sure what you are trying to do. The following simple example imagines you are trying to loop through fields in the item, searching for fields starting with SUP, containing _SUPPLIER and with a value. Adjust this logic as your naming convention needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note indexOf() tests whether the string exists, and its position. So indexOf() === 0 means "starts with".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then we take the other item, and store it as temp variable (line 7).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I loop over the fields in the other item (using f2) and for those fields starting with TOOL_COST_ and having a value, I am just adding their value to subTotal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Line 14 is example how to set some imaginary field (TOOLING_COST) in the other item to this subtotal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally line 19 is setting some imaginary field on the original item.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is trivial example, but hopefully shows all the things you might want to do when navigating the items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is flexible coding. But code should be understandable by your colleagues too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are more comfortable writing indiviaul lines of code refering to fields explicitly... even if you have to adjust that code when the fields change... that is perfectly OK too.&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="total_example.jpg" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/913146iBDB3DD087605857A/image-size/large?v=v2&amp;amp;px=999" role="button" title="total_example.jpg" alt="total_example.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 08:12:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/how-to-access-field-ids-by-looping/m-p/10277644#M1135</guid>
      <dc:creator>philipfrench</dc:creator>
      <dc:date>2021-04-29T08:12:58Z</dc:date>
    </item>
  </channel>
</rss>

