Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Deactivate workflow by SDK - Error - Only workflow definition or workflow template can be unpublished.

Posted on by 70

Hello Techies,

I'm trying to deactivate a workflow using the following code

var activateRequest = new SetStateRequest

{

EntityMoniker = new EntityReference

("workflow", item.Id),

State = new OptionSetValue(0),//Draft = 0 Published = 1

Status = new OptionSetValue(1)//Draft = 1 Published = 2ss

};

proxy.Execute(activateRequest);

And i get the errior "Only workflow definition or workflow template can be unpublished."

Thanks & Regards,
Clement

*This post is locked for comments

  • Clement-ALBERT Profile Picture
    Clement-ALBERT 70 on at
    RE: Deactivate workflow by SDK - Error - Only workflow definition or workflow template can be unpublished.

    Hi Kishore,

    Thanks for ur reply.

    I want to deactivate the WF from SSIS (C# Script Block).

    Your example is for JavaScript.

    Just a reminder, I'm on Dynamics CRM 2015 on-premises with Update UR 0.3.

    Regards,

    Clement

  • Kishore P Profile Picture
    Kishore P 45 on at
    RE: Deactivate workflow by SDK - Error - Only workflow definition or workflow template can be unpublished.

    Hi,

    Try These :

    var data =

               {

                   "statecode" : 0,

                   "statuscode" : 1

               }

           Xrm.WebApi.updateRecord("workflows", Workflow_id, data).then(

               function success(result) {

               // Perform operations on record update

               Xrm.Utility.alertDialog("Deactivate the Workflow", null);

               },

               function (error) {

               // Handle error conditions

               Xrm.Utility.alertDialog(error.message, null);

               }

               );

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans