Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hello team,
How to get correct DocumentID right after Requirement creation in a trigger?
very simple code returns 0
theRequirementDocumentID = delta.getDocumentID();
print("*** Requirement Document ID for " + delta.getType() + " " + delta.getID() + " is: " + delta.getDocumentID());
After second Text edit it goes ok though.
But I need to get DocID right after Requirement creation.
Problem in trigger Rule definition?
Now set as Type = New [Requirement]
Many thanks,
Solved! Go to Solution.
var apiSession = environmentBean.createAPISessionBean();
var runner = apiSession.createAPICommandRunnerBean();
runner.setCommand("im", "<command>");
runner.execute();
Using "Document ID" field with versioning is quite risky as it could be not available for versioned item (usually it's there only for live items).
Hi @AN_10548594,
"Document ID" field is being calculated after creation of an item.
Try to execute your logic in a "Post" trigger which will run after your new requirement is saved to DB.
Hi pal,
Thanks for help!
I can't use post trigger as i'm going to modify my requirement.
I'm trying to set computed upstream and downstream object names in custom fields to make them look nicer in Excel.
Anyway in my case the solution could be the fact that a computed number should have a version number as a postfix. That means to make it all work user should hit F3 on content to create a mior or major version. After that all triggers are ok to run.
Regards,
var apiSession = environmentBean.createAPISessionBean();
var runner = apiSession.createAPICommandRunnerBean();
runner.setCommand("im", "<command>");
runner.execute();
Using "Document ID" field with versioning is quite risky as it could be not available for versioned item (usually it's there only for live items).
Thanks a lot again!
Very usefull and seems like a solution for my case.
Will check and let you know,
PS. Hi )))
Hi again,
And this is what TS says about this:
"The document ID is stored in a field named Document ID. When a new item is created, the value of the Document ID field hasn't been commited yet during the PRE trigger phase.
To get the document ID of a newly created item in a PRE Trigger, use the getNewFieldValue("Document ID") method on the ScriptIssueDeltaBean."
Regards
And this is wrong answer from TS