Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)
Posted on by 20

Testing

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Setting date to First of the Month in a Workflow

    Aric levin, how you have taken the filed name and how you would trigger the field.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Setting date to First of the Month in a Workflow

    what is your field name levin. Can you elaborate the code briefly?

  • Suggested answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: Setting date to First of the Month in a Workflow

    You might try using these components:

    github.com/.../CRM-DateTime-Workflow-Utilities

    There are workflow activities to get first/last days of month (so you might just add 1 day to that in your workflow.. which is also a custom activity there)

  • carlbuquerque Profile Picture
    carlbuquerque 20 on at
    RE: Setting date to First of the Month in a Workflow

    Test

  • nfernandezba Profile Picture
    nfernandezba 210 on at
    RE: Setting date to First of the Month in a Workflow

    Carl,

    What should trigger the date update? To which records?

    I'm thinking a no-code solution, but I need this information to analyze the viability.

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Setting date to First of the Month in a Workflow

    You can create a custom workflow activity. Should be fairly simple. Build it and deploy using Plugin Registration Tool.

    If you have not done this before, check the following link:

    msdn.microsoft.com/.../gg328515.aspx

    using System;

    using System.Activities;

    using Microsoft.Xrm.Sdk.Workflow;

    namespace XrmWorkflowTools

    {

       public class GenerateDate : CodeActivity

       {

           #region Input/Output Parameters

           // Not Required. Just to have input parameter

           [Input("DateFormat")]

           [RequiredArgument]

           public InArgument<string> DateFormat { get; set; }

           [Output("Output Date")]

           public OutArgument<DateTime> OutputDate { get; set; }

           #endregion

           protected override void Execute(CodeActivityContext executionContext)

           {

               DateTime currentDate = DateTime.Today;

               DateTime nextDate;

               if (currentDate.Month == 12)

                   nextDate = new DateTime(currentDate.Year + 1, 1, 1);

               else

                   nextDate = new DateTime(currentDate.Year, currentDate.Month + 1, 1);

               OutputDate.Set(executionContext, nextDate);

           }

       }

    }

    Hope this helps.

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Setting date to First of the Month in a Workflow

    No my friend you have to write a custom code for this may custom workflow or plugin.

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans