Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

dmsID of a record Created using createNewItem

6 REPLIES 6
Reply
Message 1 of 7
BiggePLM
1167 Views, 6 Replies

dmsID of a record Created using createNewItem

I know that using the createNewItem Library script will allow you to then assign the object created and stored in the newItem variable to a linked picklist field based on the workspace where the new item is created.

 

Can you also get the dmsID of the record that was created?

 

Simply;

 

var newProperties = [];
newProperties.FIELD1 = Value1;
newProperties.FIELD2 = Value 2;

var newItem = createNewItem('TARGET_WS', newProperties);

 

if (newItem !== null){

     println(newItem.descriptor.dmsID) //not sure what to put here to get the dmsID?

}

 

BD

 

 

 

BD

6 REPLIES 6
Message 2 of 7
gasevsm
in reply to: BiggePLM

That is correct: newItem.descriptor.dmsID

--

Martin Gasevski


Martin Gasevski | Fusion 360 Team Product Manager
Message 3 of 7
BiggePLM
in reply to: BiggePLM

Martin,

 

That is what I thought but I get the following error when I run this code:

 

// Add New Drawing Record to Engineering Master Drawing List workspace
var newProperties = [];
newProperties.PROPOSAL = ProposalLink;
newProperties.DRAWING_ID = item.descriptor.dmsID;
newProperties.DRAWING_REFERENCE = "TEST";

var newItem = createNewItem('WS_DRAWING_LIST', newProperties);

if (newItem !== null)
{
var LookupList = loadItem("40203");
// Get current list of records
var currentRecordsList = LookupList.RECORDSLIST;
// Create new list of records by appending the delimiter and the current item's dmsID
if (currentRecordsList !== null)
{
var newRecordsList = currentRecordsList + "|" + newItem.descriptor.dmsID;

}
else
{
var newRecordsList = newItem.descriptor.dmsID;
}
// Set the new list of records on the records list
LookupList.RECORDSLIST = newRecordsList;
}

 

TypeError: Cannot read property "dmsID" from null

 

and the error points to the line where I refernce the newItem.descriptor.dmsID" (Line Highlighted in RED)

 

I am betting it has to do with the timing of the call?

 

This code is run from the On-Create behavior after additional code for updating fields for new records.

 

BD

 

BD

Message 4 of 7
BiggePLM
in reply to: BiggePLM

Still can't get this to work?

 

Anyone tried to capture the dmsID of a record created through the createNewItem Library Function?

 

BD

Message 5 of 7
gasevsm
in reply to: BiggePLM

BD,

 

someItem.descriptor.dmsID works for any item you have access to (whether its linked or loadItem) that existed prior launching the script. It doesn't work for newly spawned items because the item has yet to be persisted in PLM, which is not until after the script has completed running at which point we assign new DMS IDs to such.

 

Hope this helps,

--

Martin Gasevski


Martin Gasevski | Fusion 360 Team Product Manager
Message 6 of 7
ThomasRambach
in reply to: gasevsm

@gasevsm not helpful if you want to create a new task and email a link out to the item.

Message 7 of 7
gasevsm
in reply to: ThomasRambach

Hi Thomas,

Totally understand and agree. Roughly speaking, and in an oversimplified way, currently we have an On-createItem scripting action handler ie. runs inmem context of the item being created, whereas the ask seems to be one of a Post-createItem scripted action. Currently until the item is committed, there is no guarantee so to speak of the dmsid assignment, hence its unreliable until after item’s creation. But I totally understand the ask, just not certain how to accomplish this today short of delegating to another event eg. a hidden loop wf transaction on the very first wf State that would take the role of emailing a link to folks once a fully fledged dmsid is materialized. Of course, it requires more creativity if the workspace isnt workflow-aware. An elegant, native solution isnt available in the product today.

Hope this helps,


Martin Gasevski | Fusion 360 Team Product Manager

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report