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
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
Still can't get this to work?
Anyone tried to capture the dmsID of a record created through the createNewItem Library Function?
BD
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
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,