Stuck.. Update "Impact" Drop Down on Incident Form via Custom.js
Hi All,
We have a special "VIP" impact level. Whenever the affected user happens to be a VIP user we want to auto-update the impact to be "VIP", so that the SLA's are changed accordingly. I know its possible to do this via an "Incident Event Workflow" in Service Manager, but I would prefer to do it on the fly in the portal if possible.
Unfortunately, I cant figure out how to update the Impact kendo drop down list.
Whatever I try, it never seems to update. Any assistance with this would be much appreciated.
Here is what I have so far (which does not work)
/*<br> For VIP Users, Updates Status of Call to "VIP"<br>*/<br>function updateStatusToVIP(userPickerId, userPickerObject) { <br> if (pageForm.viewModel.Impact.Name != "VIP") {<br> pageForm.viewModel.Impact.set("Name", "VIP");<br> pageForm.viewModel.Impact.set("Id", "05f71590-efec-c7ab-5940-68317db0b036");<br> alertify.log("<b>!! VIP User Detected !!</b><br><i>Impact</i> automatically updated to <b>VIP</b>.<br>")<br> }<br>}
Best Answers
-
Geoff_Ross Cireson Consultant O.G.Hi Adrian,
Couple of options here:
What you are doing above, will set the data in the viewModel but not update the DOM. Therefore you could just call the page.Save() function to save and reload the page when this is triggered and the new Impact will ten be reflected on the form.
Alternatively, if you want to update the DOM without a refresh, you need to grab the whole Enum Value object via the API and set Impact to that. In pseudo code:Get Enum List for Impact
Loop through and find the object were Id = 05f71590-efec-c7ab-5940-68317db0b036
Place the object in a variable
Set Impact to this variable
Let me know if this doesn't make sense of you need the code fleshing out a bit.
Geoff6 -
Roland_Kind Partner Advanced IT Monkey ✭✭✭Hi Adrian,
regarding " ....Unfortunately, I cant figure out how to update the Impact kendo drop down list. "
the following code snipped might be helpful ... (this worked in 6.0.2 & Risk enum)
$('[data-role=Risk]').each(function (index){
$(this).data('kendoExtDropDownTreeViewV3')._dropdown.value(GUID_of_enum_var)
});
regards
Roland5
Answers
Couple of options here:
What you are doing above, will set the data in the viewModel but not update the DOM. Therefore you could just call the page.Save() function to save and reload the page when this is triggered and the new Impact will ten be reflected on the form.
Alternatively, if you want to update the DOM without a refresh, you need to grab the whole Enum Value object via the API and set Impact to that. In pseudo code:
Let me know if this doesn't make sense of you need the code fleshing out a bit.
Geoff
Thanks Geoff!
Much appreciated. I will have a look at this later today and give it a go.
Regards,
Adrian
regarding " ....Unfortunately, I cant figure out how to update the Impact kendo drop down list. "
the following code snipped might be helpful ... (this worked in 6.0.2 & Risk enum)
$('[data-role=Risk]').each(function (index){
$(this).data('kendoExtDropDownTreeViewV3')._dropdown.value(GUID_of_enum_var)
});
regards
Roland
Thanks Roland,
I will give this a go.
Cheers,
Adrian
This did the trick!
Thanks Roland.
So my final code was as follows:
enumVIP = "05f71590-efec-c7ab-5940-68317db0b036"
$('[data-role=Impact]').each(function (index){
$(this).data('kendoExtDropDownTreeViewV3')._dropdown.value(enumVIP)
});
pageForm.viewModel.Impact.set("Name", "VIP");
pageForm.viewModel.Impact.set("Id", enumVIP);