locked
Workflow not working when trying to update values RRS feed

  • Question

  • I am trying to update 3 fields in contact form through my Last completed Phone call activity. I have a custom button on my main CRM Ribbon "Add Activity". When a contact is selected and this button is clicked a phone call activity form opens up with due date, and few other fields auto-populated  When "Mark Complete" is clicked the workflow should run and update the due date field in the Contact page from the completed phone call activity. My workflow is not working. It does not proceed further after the first if condition "If Phone Call-> Activity Status = Complete". Although the status is completed. And the workflow is in waiting condition. Any help would be greatly appreciated
    Monday, February 11, 2013 10:48 AM

Answers

  • Ok! Now is better. It shows that the populated regarding object field did not pass to the workflow correctly. On which event did you put your handler of the javascript? OnLoad? With the debugger of the IE (using F12) check if the regarding object has value! Remember,  that regarding object field is an "activity party" and setting entity reference with that is not simple. You have to first find the activity party id, and then through the "party id" of that activity party set the entity reference.

    If the answer helped you, remember to mark it as answer.

    • Marked as answer by Fareeha CH Wednesday, February 13, 2013 6:09 AM
    Tuesday, February 12, 2013 10:10 AM
    Moderator
  • You can use the following to set value of activity party fields:

    var lookupValue = new Array();
    lookupValue[0] = new Object();
    lookupValue[0].id = <sender guid>;
    lookupValue[0].name = <Display Name>;
    lookupValue[0].entityType = <From entity type name>;
    
    
    Xrm.Page.getAttribute('regaringobject').setValue(lookupValue);


    If the answer helped you, remember to mark it as answer.

    • Marked as answer by Fareeha CH Wednesday, February 13, 2013 6:09 AM
    Tuesday, February 12, 2013 10:33 AM
    Moderator
  • Try to set your reference with the above mentioned method. Then, debug the code to see the regarding object has value. At the end, the completed phonecall should be appeared in the closed activities of the contact.

    If the answer helped you, remember to mark it as answer.


    Tuesday, February 12, 2013 11:01 AM
    Moderator

All replies

  • Check the date field you are trying to update is not a readonly field. If so, first change it to  enabled on the form, then deactivate and activate your workflow, then disable the field. If did not work, delete the workflow and create it when the field is enabled, then disable the field. If the problem is the disabled field, this procedure could help you, otherwise, provide the error log and give a snapshot of the failed workflow.

    If the answer helped you, remember to mark it as answer.


    Monday, February 11, 2013 11:58 AM
    Moderator
  • I am trying to update 3 fields in contact form through my Last completed Phone call activity. I have a custom button on my main CRM Ribbon "Add Activity". When a contact is selected and this button is clicked a phone call activity form opens up with due date, and few other fields auto-populated  When "Mark Complete" is clicked the workflow should run and update the due date field in the Contact page from the completed phone call activity. My workflow is not working. It does not proceed further after the first if condition "If Phone Call-> Activity Status = Complete". Although the status is completed. And the workflow is in waiting condition. Any help would be greatly appreciated

    As i know, you cant edit any information in entity that has status = complete. 

    Also, if you close your opportunity as won\lost - you don't be able to edit this string of entity. 

    So, i recomend you to review your business-proces... and assign status "complete" automaticly with worck-flow.

    Monday, February 11, 2013 12:01 PM
  • I am trying to update 3 fields in contact form through my Last completed Phone call activity. I have a custom button on my main CRM Ribbon "Add Activity". When a contact is selected and this button is clicked a phone call activity form opens up with due date, and few other fields auto-populated  When "Mark Complete" is clicked the workflow should run and update the due date field in the Contact page from the completed phone call activity. My workflow is not working. It does not proceed further after the first if condition "If Phone Call-> Activity Status = Complete". Although the status is completed. And the workflow is in waiting condition. Any help would be greatly appreciated

    As i know, you cant edit any information in entity that has status = complete. 

    Also, if you close your opportunity as won\lost - you don't be able to edit this string of entity. 

    So, i recomend you to review your business-proces... and assign status "complete" automaticly with worck-flow.

    Fareeha wants to update a date on the contact, not the activity!

    If the answer helped you, remember to mark it as answer.


    Monday, February 11, 2013 12:03 PM
    Moderator
  • I am trying to update 3 fields in contact form through my Last completed Phone call activity. I have a custom button on my main CRM Ribbon "Add Activity". When a contact is selected and this button is clicked a phone call activity form opens up with due date, and few other fields auto-populated  When "Mark Complete" is clicked the workflow should run and update the due date field in the Contact page from the completed phone call activity. My workflow is not working. It does not proceed further after the first if condition "If Phone Call-> Activity Status = Complete". Although the status is completed. And the workflow is in waiting condition. Any help would be greatly appreciated

    As i know, you cant edit any information in entity that has status = complete. 

    Also, if you close your opportunity as won\lost - you don't be able to edit this string of entity. 

    So, i recomend you to review your business-proces... and assign status "complete" automaticly with worck-flow.

    Fareeha wants to update a date on the contact, not the activity!

    If the answer helped you, remember to mark it as answer.


    sorry... overlooked
    Monday, February 11, 2013 12:12 PM
  • I am trying to update date and two other fields on the contact form with the value of the due date and two other fields from the phone call activity that is marked as complete. In the workflow the last prospecting is the date field in the contact form which is renamed as "Last Prospecting" on the contact page and is populated with "due Date" of completed phone call activity.I could not upload the screen shot of the workflow. So the error i am getting is A record required by this process could not be found and my workflow is :

    1. If Phonecall (Activity Status) is completed

           ->  If due date is null

                           -> If Regarding (contact) - Last Prospecting does not contain data

                            ->Update Contact

                           -> Exit

           -> If phone call (due date) is greater than contact ( Last  Prospecting)

                            -> Update Regarding (Contact)

                            -> Exit

    My workflow did not even passed the 1st if condition. even though the activity status is marked complete
    • Edited by Fareeha CH Monday, February 11, 2013 4:54 PM
    Monday, February 11, 2013 4:52 PM
  • Please check these:

    1- Do you created your workflow on the phonecall entity? Not other activity types!

    2- Do you trigger the workflow on status change?

    3- The first if "If due date is null" checks what? Is this check condition, checks the due date of a phone call? Is this really null?

    4- Do you update the "Regarding Contact" on update contact?

    The error you mentioned "A record required by this process could not be found", usually occurs when you try to update a readonly field or entity! Please check the above said.


    If the answer helped you, remember to mark it as answer.

    Monday, February 11, 2013 5:17 PM
    Moderator
  • 1. i created the workflow in phonecall entity

    2. It is triggered when a record status changes

    3. the due date condition checks if the Lead prospecting field is empty on the contact form or not.

    4. Update is done on the Last Prospecting Field in the contact. the Last prospecting field of the Regarding (contact) is updated with the due date of the completed phonecall activity.

    When i open a contact and add an activity and marks it complete the fields on the contact form are populated with the fields value of the phonecall activity (meaning the workflow works as designed). But i have added a custom button on the CRM homepage ribbon. What it does is when a contact is checked on the main page from the grid and the custom button is clicked a phone call activity opens up with the fields auto-populated with pre-defined value. But when the phone call activity is marked completed from this scenario. The 3 fields are not updated according to the workflow that was designed to work when the status of the phone call changes to complete. and following error arises that the record required by this process could not be found

    And all the three fields are not read only


    • Edited by Fareeha CH Monday, February 11, 2013 5:51 PM
    Monday, February 11, 2013 5:50 PM
  • Does your custom button works with plugin? If so, it could be because of different pipelines of the workflow and the plugin?

    What do you mean "(meaning the workflow works as designed)"? You said that the workflow even did not pass the first condition!


    If the answer helped you, remember to mark it as answer.

    Monday, February 11, 2013 6:19 PM
    Moderator
  • it worked in one scenario as i told you and it didnt work when i tried to update using the custom button. I am new to crm.so i have no idea about plugin and pipelines in it.how can i check that?
    Monday, February 11, 2013 7:23 PM
  • Use your plugin register tool to see what plugins are registered on you server? You could also use IE debugging tool (press F12 on a page) to see if a javascript is used on the button.

    If the answer helped you, remember to mark it as answer.

    Tuesday, February 12, 2013 8:41 AM
    Moderator
  • Yes js is used in the functionality of the button.  javascript is used to automatically populate the phone activity of the selected contact with the contacts name, parent customer id and also subject is also auto-populated.  So basically when a contact is selected from the main page grid and that button is clicked the phone call activity opens up. with its recipient field populated with contact name and regarding field populated with contacts parent customer field value 
    Tuesday, February 12, 2013 9:50 AM
  • I think the "regarding" field which is populated in this entity did not pass to the workflow correctly. To test this, please create a phonecall manually, which could satisfy your workflow conditions. Check if the workflow works for that. If worked, it approves my assumption.

    If the answer helped you, remember to mark it as answer.

    Tuesday, February 12, 2013 9:55 AM
    Moderator
  • if i create a phone call manually inside a contact and then marks as complete the workflow works correctly

    but when i selected a contact and then clicked on that button and marks that activity as complete the workflow didnot execute. I checked the error log. It says that the phone call activity did not find the record to update the fields. Any idea how can i solve this in my workflow so that it gets a refernce of the selected contact to be updated

    Tuesday, February 12, 2013 10:03 AM
  • Ok! Now is better. It shows that the populated regarding object field did not pass to the workflow correctly. On which event did you put your handler of the javascript? OnLoad? With the debugger of the IE (using F12) check if the regarding object has value! Remember,  that regarding object field is an "activity party" and setting entity reference with that is not simple. You have to first find the activity party id, and then through the "party id" of that activity party set the entity reference.

    If the answer helped you, remember to mark it as answer.

    • Marked as answer by Fareeha CH Wednesday, February 13, 2013 6:09 AM
    Tuesday, February 12, 2013 10:10 AM
    Moderator
  • i put the javascript code on button click .when a button is clicked a webpage dialog opens up and on that dialog a "ok" button is present. on the onclick function of that "ok" button is my code for all the javascript for auto-populating and to open the phonecall entity
    Tuesday, February 12, 2013 10:15 AM
  • So, debug to see whether the "regarding object" field has value or not. Would you please paste here your script? I think the entity reference part has problem!

    If the answer helped you, remember to mark it as answer.

    Tuesday, February 12, 2013 10:26 AM
    Moderator
  • You can use the following to set value of activity party fields:

    var lookupValue = new Array();
    lookupValue[0] = new Object();
    lookupValue[0].id = <sender guid>;
    lookupValue[0].name = <Display Name>;
    lookupValue[0].entityType = <From entity type name>;
    
    
    Xrm.Page.getAttribute('regaringobject').setValue(lookupValue);


    If the answer helped you, remember to mark it as answer.

    • Marked as answer by Fareeha CH Wednesday, February 13, 2013 6:09 AM
    Tuesday, February 12, 2013 10:33 AM
    Moderator
  • Where do you set the regarding object of the phonecall?


    If the answer helped you, remember to mark it as answer.

    Tuesday, February 12, 2013 10:49 AM
    Moderator
  •   for (var i = 0; i < gridArray.length; i++) {
                    var type = gridArray[i][1];
                    if (type == "2") {
                        contactIds += gridArray[i][0] + ";";
                        var name = RetrieveMultiplerecords("contact","contactid", gridArray[i][0], "fullname");
                        if (name != null && name.length>0)
                            ContactNames += name[0] + ";";
                        else
                            ContactNames += ";";

                        var regarding = RetrieveMultiplerecords("contact", "contactid", gridArray[i][0], "parentcustomerid");
                        if (regarding != null && regarding.length>0) {
                            ContactRegardingIds += regarding[0] + ";";
                            var regardingName = RetrieveMultiplerecords("account", "accountid", regarding[0], "name");
                            if (regardingName != null && regardingName.length > 0)
                                ContactRegardingNames += regardingName[0] + ";";
                            else
                                ContactRegardingNames = ";";
                        }
                        else {
                            ContactRegardingIds += ";";
                            ContactRegardingNames = ";";
                        }
                    }
                }
              //  debugger;
                parameters["parameter_contactIds"] = contactIds;
                parameters["parameter_ContactNames"] = ContactNames;
                parameters["parameter_ContactRegardingIds"] = ContactRegardingIds;
                parameters["parameter_ContactRegardingNames"] = ContactRegardingNames;
                window.dialogArguments.Xrm.Utility.openEntityForm("phonecall", null, parameters);
    Tuesday, February 12, 2013 10:56 AM
  • Try to set your reference with the above mentioned method. Then, debug the code to see the regarding object has value. At the end, the completed phonecall should be appeared in the closed activities of the contact.

    If the answer helped you, remember to mark it as answer.


    Tuesday, February 12, 2013 11:01 AM
    Moderator
  • ok..thanks... you were right. The regarding value was not set correctly. Thanks for helping me.
    Wednesday, February 13, 2013 6:09 AM