web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to make an Update in a retrieve plugin

(0) ShareShare
ReportReport
Posted on by

Hi guys

I need to change the value of a checkbox to trigger a workflow in crm 2013

the plugin is in retrieve and it's post operation
and the workflow starts its execution when that checkbox change its value

In fact the code itself didn't update the true or false value of the checkbox


Can you help me to make me see my error or see what I'm missing

Thanks in advance

this is my code

if (requestEntity.pwc_HasRequestItemsandInquiryType == false)
    {
       requestEntity.pwc_HasRequestItemsandInquiryType = true;
                        
                       
     }
else if (requestEntity.pwc_HasRequestItemsandInquiryType == true)
     {
        requestEntity.pwc_HasRequestItemsandInquiryType = false;
                       
      }


*This post is locked for comments

I have the same question (0)
  • Verified answer
    Bob Hatcher Profile Picture
    on at

    You have to make a new instance of the entity you want to update, then copy the ID from the existing one into the new instance. Then make updates to the new instance and update.

    Entity newEntity = new Entity("requestEntity");
    newEntity.id = priorEntity.id; // Set the id of the new one 
    newEntity["pwc_HasRequestItemsandInquiryType"] = true;
    service.update(newEntity);
  • Community Member Profile Picture
    on at

    Thanks for your answer but now when I try to open a record of the entity Request the CRM is loading and loading all the time :S

    this is the code I made based in your answer

    pwc_request newRequest = new pwc_request();
    newRequest.Id = requestEntity.Id;
    if (requestEntity.pwc_HasRequestItemsandInquiryType == false)
        {
          newRequest["pwc_hasrequestitemsandinquirytype"] = true;
         }
    else
         {
            newRequest["pwc_hasrequestitemsandinquirytype"] = false;
          }
    service.Update(newRequest);


  • Mahendar Pal Profile Picture
    45,095 on at

    Is there any other plugin, provide information about your plugin registration.

  • Community Member Profile Picture
    on at

    Thanks for your answer but No, that one is the only plugin is a retrieve plugin for a custom entity "requests" is post-operation

    I think I made the update in a wrong way or something because without the update I can open recors but if the plugin has the update of the new entity it doesn't work just keep loading loading all the time

  • Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    Why are you writing plugin on retrieve ?? any reason, what is your actual requirement, you can simply set this field using javascript, plugin on retrieve can impact performance of your CRM system.

  • Community Member Profile Picture
    on at

    The plugin has another validations to make necessary to be on retrieve

    and cannot be a javascript code because we're using this custom entity by a web client using a webService that's why I need a plugin and not a javascript webResource

    And the requirement is to trigger a workflow on the retrieve after the record is created on the web portal

    I just though to trigger the workflow when the checkbox changes its value that's what I'm doing

  • Mahendar Pal Profile Picture
    45,095 on at

    Ok, it may be that there is something wrong with the code, share your complete code here for inquiry

  • Community Member Profile Picture
    on at

    "And the requirement is to trigger a workflow on the retrieve after the record is created on the web portal"

    Why is "on the retrieve" part of your requirement?

    Firing on the create message would serve the same purpose.  Indeed you could just fire a workflow like normal when the record is created.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans