API CreateProjectionByCriteria
How do i populate the Affected User field from the API
Best Answers
-
Shane_White Cireson Support Super IT Monkey ✭✭✭✭✭
Hi Lesiba,
This is a 'simple' example, these are the properties the API requires, which you can see from the API documentation link below:
https://support.cireson.com/Help/Api/POST-api-V3-WorkItem-BulkEditWorkItems
Thanks,
Shane
5 -
Shane_White Cireson Support Super IT Monkey ✭✭✭✭✭
Hi Lesiba,
Apologies for the delay.
Below is a very simple example containing the required fields for the API and a Title field:
var wi = pageForm.viewModel;
var newTitle = 'New Title'
var original = {
BaseId: wi.BaseId,
TimeAdded: wi.TimeAdded,
Title: wi.Title
};
var current = {
BaseId: wi.BaseId,
TimeAdded: wi.TimeAdded,
Title: newTitle
};
var replacementJson = JSON.stringify({
"formJson": {"current": current, "original": original}
});;
$.ajax({
url: "/api/V3/Projection/Commit",
dataType: "json",
data: replacementJson,
success: function(result) {
app.lib.message.add('Title changed to ' + newTitle);
app.lib.message.show();
},
error: function(result, status, error) {
console.log("error function");
console.log(replacementJson);
},
type: "POST",
contentType: "application/json; charset=utf-8",
});
Let me know if this helps.
Thanks,
Shane
5
Answers
Hi @Lesiba_Malebana ,
Thanks for posting this to the community, here is an example using the Bulk Edit API! You can also use the Commit API! Just change the workitem Id to the workitem you want to edit and the edited value is the user Id you want to set the affected user as.
$.ajax({
url: '/api/V3/WorkItem/BulkEditWorkItems',
type: 'POST',
contentType: 'application/json',
data:JSON.stringify(
{
ProjectionId:"285cb0a2-f276-bccb-563e-bb721df7cdec",
UpdateServiceManagement:true,
ItemIds:["8130a4ad-eb38-eca9-531f-01690eb58e17"],
EditedFields:
[
{PropertyName:"RequestedWorkItem",
PropertyType:"singleCardinalityObject",
PropertyRelationshipId:"dff9be66-38b0-b6d6-6144-a412a3ebd4ce",
EditedValue: session.user.Id}
]
}),
dataType: 'json'
});
Let me know if this helps!
Thanks,
Shane
Hi Shane,
Apologies for a super delayed response, is it possible that the example you provided can be simplified into plain request like how we test in Postman? or with examples provided on the Cireson API Documentation.
Kind Regards
Hi Lesiba,
This is a 'simple' example, these are the properties the API requires, which you can see from the API documentation link below:
https://support.cireson.com/Help/Api/POST-api-V3-WorkItem-BulkEditWorkItems
Thanks,
Shane
Hi Shane,
Thank you very much i managed to get it to work. however can you show me how to perform the same thing with Commit API, since i need to issue 3 calls for logging calls.
Hi Lesiba,
Apologies for the delay.
Below is a very simple example containing the required fields for the API and a Title field:
var wi = pageForm.viewModel;
var newTitle = 'New Title'
var original = {
BaseId: wi.BaseId,
TimeAdded: wi.TimeAdded,
Title: wi.Title
};
var current = {
BaseId: wi.BaseId,
TimeAdded: wi.TimeAdded,
Title: newTitle
};
var replacementJson = JSON.stringify({
"formJson": {"current": current, "original": original}
});;
$.ajax({
url: "/api/V3/Projection/Commit",
dataType: "json",
data: replacementJson,
success: function(result) {
app.lib.message.add('Title changed to ' + newTitle);
app.lib.message.show();
},
error: function(result, status, error) {
console.log("error function");
console.log(replacementJson);
},
type: "POST",
contentType: "application/json; charset=utf-8",
});
Let me know if this helps.
Thanks,
Shane