Change status on File Attachment for End users
Hello,
Is it possible to change status of a request when the file is uploaded. I have the below given scenario:
Let's say request is in XYZ status. Whenever user uploads any file, the status remains XYZ. My requirement is when the file is uploaded, status of the request should be changed to Active.
Thanks in Advance,
Manas Gautam
Answers
This is a great idea! Here's a bit of js you can add to custom.js that will accomplish what you are after:
app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
if (_.has(viewModel, 'FileAttachment')) {
viewModel.FileAttachment.bind('change', function(evt){
if (evt.action === 'add' && viewModel.Status.Id !== '5e2d3932-ca6d-1515-7310-6f58584df73e') {
var status = {
Id: "5e2d3932-ca6d-1515-7310-6f58584df73e",
Name: "Active"
};
viewModel.set('Status', status);
}
});
}
});
Hello Justin,
Thanks for your response.
This code works fine but there's an issue. If the user is attaching the file for the first time, this block of code does not get executed. It works only when there is at least one existing attached file and second(or more) file is being attached.
Regards,
Manas
@Manas_Gautam - I have just tested with an incident with no attachments but in a status other than active. As soon as I added the attachment, the status changed to active. Is it possible your tests where with an incident that was already in active status?
@Justin_Workman Yes, I checked again. The incident on which I am testing this code is not in Active status. The same issue still persists. On first attachment status is not changing to Active. The ticket is in custom status input of waiting reply from end user.
@Justin_Workman Is there any modification in code or any other approach you can recommend?
Regards,
Manas