locked
How can i get a same result by using Jacascript In MS CRM ....Both Field's from the same Entity.?? RRS feed

  • Question

  • Below Is the Workflow In MS CRM:

    Step 1:


    Step 2:
    IF PRIORITY = HIGHT
    THEN:


    How can i get the same Result By using Javascript In ms CRM...?? and both field's from the Same entity.

    Thursday, August 16, 2012 4:24 AM

Answers

  • You can try this. Checks that both the Priority and Incident Date are populated and if the Priority is High - sets the date 5 more days than the Incident Date. You can hook this up to the Priority and Incident Date OnChange events.

    function OnChange() {
        if (Xrm.Page.getAttribute("prioritycode").getValue() != null && Xrm.Page.getAttribute("new_incidentdate").getValue() != null) {
            if (Xrm.Page.getAttribute("prioritycode").getSelectedOption().text == "High") {
                var date = Xrm.Page.getAttribute("new_incidentdate").getValue();
                date.setDate(date.getDate() + 5);
                Xrm.Page.data.entity.attributes.get("followupby").setValue(date);
            }
        }
    }
    

    Jason Lattimer

    Thursday, August 16, 2012 4:55 AM
    Moderator
  • function SetDateField()
     {
    var priority = Xrm.Page.data.entity.attributes.get("prioritycode");
    var optionSetText = priority.getText();
    var Incident = Xrm.Page.getAttribute("SCHEMA  NAME").getValue();  //Set the schema name of Incident Type
    if (optionSetText=="High")
    {
    var result = null;
    result = new Date(Incident);
    result.setDate(result.getDate() + 5);
    Xrm.Page.getAttribute("followupby").setValue(result);  
    }
    }
    • Marked as answer by KennyChan6996 Thursday, August 16, 2012 6:16 AM
    Thursday, August 16, 2012 5:11 AM

All replies

  • You can try this. Checks that both the Priority and Incident Date are populated and if the Priority is High - sets the date 5 more days than the Incident Date. You can hook this up to the Priority and Incident Date OnChange events.

    function OnChange() {
        if (Xrm.Page.getAttribute("prioritycode").getValue() != null && Xrm.Page.getAttribute("new_incidentdate").getValue() != null) {
            if (Xrm.Page.getAttribute("prioritycode").getSelectedOption().text == "High") {
                var date = Xrm.Page.getAttribute("new_incidentdate").getValue();
                date.setDate(date.getDate() + 5);
                Xrm.Page.data.entity.attributes.get("followupby").setValue(date);
            }
        }
    }
    

    Jason Lattimer

    Thursday, August 16, 2012 4:55 AM
    Moderator
  • function SetDateField()
     {
    var priority = Xrm.Page.data.entity.attributes.get("prioritycode");
    var optionSetText = priority.getText();
    var Incident = Xrm.Page.getAttribute("SCHEMA  NAME").getValue();  //Set the schema name of Incident Type
    if (optionSetText=="High")
    {
    var result = null;
    result = new Date(Incident);
    result.setDate(result.getDate() + 5);
    Xrm.Page.getAttribute("followupby").setValue(result);  
    }
    }
    • Marked as answer by KennyChan6996 Thursday, August 16, 2012 6:16 AM
    Thursday, August 16, 2012 5:11 AM