Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Execute Multiple Change status Request

Posted on by Microsoft Employee

I am trying to execute multiple request (Transaction) against Dynamic CRM.

I know how to create update/create request, as below:

        CreateRequest createRequest = new CreateRequest { Target = entity };


One of my request is change status request. but i don't know how to create change request.

*This post is locked for comments

  • Verified answer
    Akhil101 Profile Picture
    Akhil101 432 on at
    RE: Execute Multiple Change status Request

    Hi Saeid,

    Use the below code: function call ChangeStatusReason(service, recordGuid, entitySchemaName, outstandingamount);

    private void ChangeStatusReason(IOrganizationService service, string recordId, string entityName, decimal outstandingamount)

           {

               Entity entActivate = new Entity(entityName);

               SetStateRequest setStateActivate = new SetStateRequest();

               setStateActivate.EntityMoniker = new EntityReference();

               setStateActivate.EntityMoniker.Id = new Guid(recordId);

               setStateActivate.EntityMoniker.Name = entityName;

               setStateActivate.EntityMoniker.LogicalName = entActivate.LogicalName;

               //Change Status to Paid if outstanding amount is 0 else Partially Paid

               if(outstandingamount == 0)

               {

                   setStateActivate.State = new OptionSetValue();

                   setStateActivate.State.Value = 0;

                   setStateActivate.Status = new OptionSetValue();

                   setStateActivate.Status.Value = 4;

                   service.Execute(setStateActivate);

               }

               else if (outstandingamount > 0)

               {

                   setStateActivate.State = new OptionSetValue();

                   setStateActivate.State.Value = 0;

                   setStateActivate.Status = new OptionSetValue();

                   setStateActivate.Status.Value = 2;

                   service.Execute(setStateActivate);

               }

           }

    Hope this helps.

    Please marks the answer as yes.

    Thanks

    AKHIL

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Execute Multiple Change status Request

    You can use a SetStateRequest to change the status of a record

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans