RE: Contact Option Set field upgrade trigger phone call activity
Hi CRMKEY,
You need create workflow and js together to achieve it, workflow is used to capture original rank value, js is used to compare new rank and original rank value and create phone call.
1.Create a global option set field and create two local option set fields that using the global option set field in contact entity.
(1)Global option set field:
Set Rank1-Rank5 value are 1-5, which make compare value in the later steps easily.
(2)Local option set fields:
2.Add two local option set fields to the contact form, then save and publisj.
3.Create a real-time workflow
Make sure to uncheck “Run this workflow in the background (Recommended)” option.
Save and Active it.
3.Write js code and add it to web Resource.
function CompareValue(executionContext) {
var formContext = executionContext.getFormContext();
var contactID = formContext.data.entity.getId().replace('{', '').replace('}', '');//current contact id
var Rank = formContext.getAttribute("new_rank").getValue();//new rank value
var RankText = formContext.getAttribute("new_rank").getText();//new rank text
var OldRank = formContext.getAttribute("new_oldrank").getValue();//old rank value
//create phone call when rank upgrade
if (Rank > OldRank) {
//Create Phone Call
var entity = {};
entity.subject = "Your Rank have upgraded to " RankText;//set phone call subject with new rank text
entity["regardingobjectid_contact@odata.bind"] = "/contacts(" contactID ")";//set phone call regardng field with current contact
Xrm.WebApi.online.createRecord("phonecall", entity).then(
function success(result) {
var newEntityId = result.id;
},
function (error) {
Xrm.Utility.alertDialog(error.message);
}
);
}
else
{
alert("Rank not upgrate");
}
}
4.Add it to contact onSave event.
5.Test:
Before:
After:
Change Rank field to 'Rank3', then click save button.
oldRank field will be filled with original value and phone call will be created automatically.
Regards,
Leah Ju
Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.