Create artifact with RM API in RDNG
Hello!
I'm trying to create several artifacts as described by next link:
First artifact is created without a problem. But I have a strange message taken from result.message if a second artifact is to be created next in a loop:
Creation unsuccessful because of 'Unable to load https://win2012:9443/rm/resources/MB_b665c1021daf40c69407751f4f1b58ea?targetFolder=https://win2012:9443/rm/folders/_eJsyNUpAEemvHrcy96PHnA&afterSibling=https://win2012:9443/rm/resources/MB_259a805cb026484991f10b5aa8190024 status: 409'
At the same time, next message is displayed on Web page:
The artifact cannot be placed at the specified location in the module.hide details
ID CRRRW7756W While you were working in the module, another user might have changed and saved it. Refresh the module and try again.
Is it possible to create several artifacts with RM API somehow? What is missing by me in this code?
Thank you!
One answer
It seems that next RM.Data.Module.createArtifact must be put into callback of the previous one. I mean that the next construction is wrong:
RM.Data.Module.createArtifact(attrs, strategy, function(result2) {
if (result2.code === RM.OperationResult.OPERATION_OK) {
//...
}
});
RM.Data.Module.createArtifact(attrs, strategy, function(result3) {
if (result3.code === RM.OperationResult.OPERATION_OK) {
//...
}
});
But the next one works:
RM.Data.Module.createArtifact(attrs, strategy, function(result2) {
if (result2.code === RM.OperationResult.OPERATION_OK) {
//...
RM.Data.Module.createArtifact(attrs, strategy, function(result3) {
if (result3.code === RM.OperationResult.OPERATION_OK) {
//...
}
});
}
});