For Example If I selected :
High priority will change the Due Date to Todays Date.
Normal priority will push the Due Date back 7 days from Today.
Low priority will push the Due Date back 14 days from Today.
Standby priority will push the Due Date back 30 days from Today.
So, How'd I do this?
I created two fields in CRM 4.0
One is called datedue, which is a basic date field
The second is a Priority picklist with the following types:
Low
Medium
High
Standby
- Open up the Main Form
- Change properties on the Priority Field
- Click Events Tab
- Edit onChange
- Check that the Event is enabled
- Paste the following code:
var PRIORITY_HIGH="High";
var PRIORITY_NORMAL="Medium";
var PRIORITY_LOW="Low";
var PRIORITY_STANDBY="Standby";
var DUE;
var TODAY;
{
TODAY = new Date();
// If Due Date is null, set it to today's date.
DUE = crmForm.all.new_datedue.DataValue;
if (DUE == null)
{
DUE = new Date();
}
// Set the due date based on the value of the Priority field.
switch (crmForm.new_priority.SelectedText) {
case PRIORITY_HIGH:
DUE = TODAY;
break;
case PRIORITY_LOW:
DUE = TODAY.setDate( TODAY.getDate() + 14);
break;
case PRIORITY_NORMAL:
DUE = TODAY.setDate( TODAY.getDate() + 7);
break;
case PRIORITY_STANDBY:
DUE = TODAY.setDate( TODAY.getDate() + 30);
break;
}
crmForm.all.new_datedue.DataValue = DUE;
}
- Save and Close, Test Changes, Publish the Entity
No comments:
Post a Comment