Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

msdyncrmWorkflowTools String Function

  • 1.  msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted Sep 11, 2019 11:53 AM
    This is a little CRM related but mostly workflow tool solution related.  Any help is appreciated.

    I'm trying to use the string function in the solution.  I want to pull out the first 13 characters following the first occurrence of ABCD in the Case Title.  I just can't figure out what the setting in the step should be, especially the regular expression.

    Can anyone help?  I've been searching and trying different expressions but can't seem to get remotely close.  Is there better documentation on the workflow tools that is hiding some where?

    Again, any help is appreciated.

    Thanks,




    ------------------------------
    Jim Corriveau
    A.W. Chesterton Company
    Groveland MA
    ------------------------------
    Conference-CRMUG_200x200


  • 2.  RE: msdyncrmWorkflowTools String Function

    Posted Sep 12, 2019 05:09 AM
    Hi Jim
    I think you are going to have to do this as a set of individual steps.

    Step 1 = String including ABCD
    Step 2 = get rightmost 13 characters of item calculated on step 1

    So
    Step 1, Capitalize all words should be true. leave everything else as default except Regular Expression which should be (ABCD)(.*)
    Step 2. Input Text = Result of step 1, Substring start = 3, Substring length = 13

    Enjoy





    ------------------------------
    Paul Smith
    SSAFA
    London
    ------------------------------

    Conference-CRMUG_200x200


  • 3.  RE: msdyncrmWorkflowTools String Function

    Posted Sep 12, 2019 08:47 AM
    Edited by Jason Shires Sep 12, 2019 08:54 AM
    Jim,

    I ran into pretty much the same problem when trying to use this tool.   I had to substring a description down to 1,720 characters.    Here the how I setup the input properties.

    Not sure if you can see it in the image, but the Regular Expression value is: "test":"(.+?)"
    Here is the example I used: https://github.com/demianrasko/Dynamics-365-Workflow-Tools/blob/master/docs/String%20Functions.md

    Workflow Substring


    ------------------------------
    Jason Shires
    Bob Evans Restaurants
    New Albany OH
    ------------------------------

    Conference-CRMUG_200x200


  • 4.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted Sep 12, 2019 11:02 AM

    Hi @Jim Corriveau,

    I believe you want "ABCD(.{13})​" This is more or less off the top of my head and untested, but ABCD finds those exact letters. The parenthesis specifies that you want the grouping of what's inside of it. The "." means any character. The {13} means any character 13 times.

    I'd actually use the regex.replace activity.  The replacement value would be just "$1", meaning it will return only the first grouping, instead of the entire match.  If you don't use this, it will return the entire match, including the ABCD, which you'd then have to separate out using a second step, as suggested by @Paul Smith above. The pattern would be the regular expression of course.

    This is all assuming your case titles have only one ABCD in them. If multiple, things may get more complex.

    Not really related, but you'll note on my github I submitted a pull request to add multiline support for the regex. You can get the source code here: https://github.com/ryanperrymba/CRM-String-Workflow-Utilities.  I don't think @Jason Lattimer has had a chance to review it yet, so the multiline option is not part of the standard package yet.

    Cheers!



    ------------------------------
    Ryan Perry
    Business Systems Analyst
    Auric Solar
    ------------------------------

    Conference-CRMUG_200x200


  • 5.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted Sep 13, 2019 03:05 AM
    Ryan, Jason, Paul - thank you for your help.  In the end, I got it done in one step and this is what i used.


    Thanks again for everyone's help,



    ------------------------------
    Jim Corriveau
    A.W. Chesterton Company
    Groveland MA
    ------------------------------

    Conference-CRMUG_200x200


  • 6.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted Sep 13, 2019 09:44 AM
    Congrats. I'd have expected that would also include the ABCD in your result, as it would return the full result, not just the first grouping. Is the substring trimming the ABCD out for you?  If so, I didn't realize you could implement both the substring and the regex at the same time manner.  Learn something new every day.

    ------------------------------
    Ryan Perry
    Business Systems Analyst
    Auric Solar
    ------------------------------

    Conference-CRMUG_200x200


  • 7.  RE: msdyncrmWorkflowTools String Function

    Posted Sep 16, 2019 08:05 AM
    I'm not sure the regex is actually doing anything.   When I used the substring functionality I was forced to put something into the regex field before I could save the form.

    ------------------------------
    Jason Shires
    Bob Evans Restaurants
    New Albany OH
    ------------------------------

    Conference-CRMUG_200x200


  • 8.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted 13 days ago
    Well I'm at it again - this time i need to parse all characters between parenthesizes in a string.  The string will have only one open ( and one close ), the string will have an unknown number of characters before and after () and the number of characters between the parenthesizes is unknown, i only know i need all characters between them.

    I've just started looking into this and any help is appreciated.  When i figure out how to do it i'll post my string function result back here...

    Thank you,

    ------------------------------
    Jim Corriveau
    A.W. Chesterton Company
    Groveland MA
    ------------------------------

    Conference-CRMUG_200x200


  • 9.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted 13 days ago
    Edited by Ryan Perry 13 days ago
    I believe the pattern would be \((.+)\)
    • External parenthesis with the backslashes indicate you are looking for something within parenthesis.
    • Internal parenthesis are the capturing group surrounding what's inside.
    • .+ means one or more characters.  If zero characters are possible, it use .* instead.

    Your replacement value would simply be $1. Why / what does this mean? The replacement value can be list of values, each value is identified by a $1,$2,..., corresponding to the capturing groups in the pattern. By numbering them, you can change their order / insert other characters in the replacement, but it sounds like this is not necessary in this case. 

    Best! 



    ------------------------------
    Ryan Perry
    Business Systems Analyst
    Auric Solar
    ------------------------------

    Conference-CRMUG_200x200


  • 10.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted 13 days ago
    Edited by Ryan Perry 13 days ago
    Correction

    Use pattern (.*\().+(\).*)
    Replacement value $1{Your replacement text here}$2
    This will find everything up to and including the left parenthesis as group $1, and everything including the closing parenthesis on, as group 2. The replacement value then copies those groups into the $1 and $2 locations around {yourreplacementtext} in the replacement string.

    Let me know if that works.

    ------------------------------
    Ryan Perry
    Business Systems Analyst
    Auric Solar
    ------------------------------

    Conference-CRMUG_200x200


  • 11.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted 13 days ago
    The first example just extracts the letters in the parenthesis. The second allows you to replace them.

    ------------------------------
    Ryan Perry
    Business Systems Analyst
    Auric Solar
    ------------------------------

    Conference-CRMUG_200x200


  • 12.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted 13 days ago
    Ryan,

    The first example \((.+)\) is so close!  It extracts the text but the parenthesis are included.  Is there a way to +1 at the beginning and -1 at the end?

    This is a huge help, thank you.


    ------------------------------
    Jim Corriveau
    A.W. Chesterton Company
    Groveland MA
    ------------------------------

    Conference-CRMUG_200x200


  • 13.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted 13 days ago
    Edited by Ryan Perry 13 days ago
    Sorry.  I was a bit confused as to if you were extracting the value or replacing it.
    It sounds like you are getting the entire match, not the matching group $1.    When regex runs, it will return the full result, but also return the individual matching groups if specified. The find activity may only return the full  match. The replace activity will allow you grab specific matching groups.Send me an email / let's hop on a call.
    ryan.perry@auricenergy.com

    ------------------------------
    Ryan Perry
    Business Systems Analyst
    Auric Solar
    ------------------------------

    Conference-CRMUG_200x200


  • 14.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted 13 days ago
    Edited by Ryan Perry 12 days ago
    [^)(]+\@[^)(]+\.[^)(]+(?!.*\(.*\).*) //Finds only last one.

    (?<=\()[^)(]+\@[^)(]+\.[^)(]+(?=\)) //Finds all instances. 


    Will return an email address contained within parenthesis, ommitting the parenthesis and broader string.
    Any regex guys able to simplify, would love to see it.

    ------------------------------
    Ryan Perry
    Business Systems Analyst
    Auric Solar
    ------------------------------

    Conference-CRMUG_200x200


  • 15.  RE: msdyncrmWorkflowTools String Function

    TOP CONTRIBUTOR
    Posted 12 days ago
    Ryan,

    Thank you for the call and taking your time on this.  I'm going with the 'find only last one' and will post back if i get the entire process working.  It would not have been possible without your help.

    Thanks again,

    ------------------------------
    Jim Corriveau
    A.W. Chesterton Company
    Groveland MA
    ------------------------------

    Conference-CRMUG_200x200


If you've found this thread useful, dive deeper into User Group community content by role