Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Need help creating a workflow that appends part of a text field when another text field changes

Posted on by Microsoft Employee

Hello, I have created a workflow that takes a text field called "Opportunity Name" and appends it by adding a separate text field called "Doc. Number" to the end of it.  For example, if the "Opportunity Name" is "TestOpportunity", and "[CHI12233]" gets typed in the "Doc. Number" field, the Opportunity Name field will get updated to be "TestOpportunity [CHI12233]".  This is working.  However, I want to be able to append the Opportunity Name field when the Doc. Number field gets updated.  It seems that using a workflow, I can only add another "Doc. Number" to the end of the "Opportunity Name" text by setting the workflow to "Append with Doc. Number".  However, this would add a 2nd Doc. Number and not delete the first Doc. Number that is in the Opportunity Name.  The other option would be to have the workflow "Clear" all the text in the current Opportunity Name, and then "Append with" something.  If I went with this option, there doesn't seem to be a way to append with just the first part of the Opportunity Name, that doesn't include the Doc. Number at the end of it.

How can I create a workflow that replaces the "Doc. Number" that is shown at the end of the "Opportunity Name" when the actual "Doc. Number" field is updated?

Thanks!

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need help creating a workflow that appends part of a text field when another text field changes

    Hi Kokulan,

    This method actually may be an option for us if the standard "Name" field is editable and able to change from a "Text" field to a calculated field.  However, I can't seem to change this field's properties, which I assume is because its an out of the box field in the "Opportunity" entity.  Is it possible to change this field's properties to be a calculated field?

    If not, is there maybe a CWA we could use to append the Opportunity Name field with the new Doc. No?

    Thanks!!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need help creating a workflow that appends part of a text field when another text field changes

    Hi @Kokulan,

    This is not an option, as we need to use the system-generated "Name" field.

  • Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Need help creating a workflow that appends part of a text field when another text field changes

    Hi

    Sorry, I meant you could create a new field (calculated type) that combines both primary name field and your Doc Number field values. Will that not work for you, If creating new field is not an option for you, let me know.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need help creating a workflow that appends part of a text field when another text field changes

    Hi @Kokulan,

    I don't believe this will work as the Opportunity Name cannot be a new field, it needs to be the primary "name" field for the opportunity.  It is a pre-created text field which I can't seem to change to a calculated field.  If you could suggest other options that would be excellent.  Thanks!!

  • Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Need help creating a workflow that appends part of a text field when another text field changes

    I should be able to suggest other options but just wanted to check if the following will work for you

    Keep the current Opportunity Name field as is. Create New field to reflect that its Opportunity Name with Doc Number. And in your workflow set the new field value to  Opportunity Name + Doc Number field. And whenever Opportunity name changes or Doc number changes, you just update the new field with the updated value.  If this idea will work for you, you may not even need workflow, you could just create a calculated field to do this.

    Let me know if the above option won't work for you

  • Dmytro Rutkovskyi Profile Picture
    Dmytro Rutkovskyi 1,835 on at
    RE: Need help creating a workflow that appends part of a text field when another text field changes

    @tgiard

    Than I recommend to implement this as form customization (probably your customers will modify the data only through the CRM form - correct?),

    In that case you can write simple logic with JavaScript to update only part in brackets ("[*]") on every update of Doc.Number, and let customers to update Opportunity name.

    If you have wider usage (Api, Excel import, 3rd party) - than you need to implement plugin, or action in language like C# to execute such logic. Or you may consider using Logic Apps (Flows), which has much more powerfull transformation tools comparing to standard workflows.

    Dmytro

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need help creating a workflow that appends part of a text field when another text field changes

    Hi @Kokulan,

    As I mentioned in my comment above, I don't believe this approach would work, as people may want to change the name of the opportunity after the opportunity has already been created.  If that is the case, the "original opportunity name" would not be showing the correct name.  Is there a way around this?  Could you explain some of the other ways to achieve this that you mentioned?

    Thanks so much!

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Need help creating a workflow that appends part of a text field when another text field changes

    Hi

    There are a few different ways to achieve what you are trying to do, the following if one of them.

    Create another field on the entity, and let's call it Original Opportunity Name.  Set the opportunity name to this field before you append the Opportunity Name with Doc Number. And then whenever the Doc Number changes, you can set the Opportunity Name to  Original Opporunity Name + Doc Number.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need help creating a workflow that appends part of a text field when another text field changes

    Hi @Dmytro,

    I'm not sure this would work, as users may want to manually change the beginning portion of the "Opportunity Name" after the opportunity has been created.  If that is the case, the "original opportunity name" would not get updated.  Is there a way around this?

  • Suggested answer
    Dmytro Rutkovskyi Profile Picture
    Dmytro Rutkovskyi 1,835 on at
    RE: Need help creating a workflow that appends part of a text field when another text field changes

    For this reason you need to save original "Opportunity Name" into the different field (probably you need to create this one, let it be "original opportunity name"), and add step to set it if this is not set before you appending "Opportunity Name" field.

    After that you can change condition - to build Opportunity Name as "original opportunity name".append("Doc.Number").

    If you want more complex logic, you can write JavaScript form customization, or action, or plugin, which will replace part of the string using some rules, but this will require some deeper level of customization and not so easy.

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans