16

Any way to get the susbstring from the start of the string until a specific character in a SharePoint designer workflow action? I cannot use "Extract Substring from Start of String" because there isn't a set number of characters I want to copy.

I need to get "1 Year" or "3 Months" from the below strings:

"1 Year|5ff55ee4-5a60-2132-bc02-bbfdd9f190ab"

"3 Months|b553caa2-fww7-4c7f-b84e-22788d26386a"

4
  • has any one got something on above? Please let me know.. additionally NO CODE DEPLOYMENT option.... Thank You. Addtionally my initial part is keep on changing.. i mean it will be like John Cena|5ff55ee4-5a60-2132-bc02-bbfdd9f190ab david mcarther|5ff55ee4-5a60-2132-bc02-bbfdd9f190ab ross kapito|5ff55ee4-5a60-2132-bc02-bbfdd9f190ab
    – user17734
    Jun 20, 2013 at 5:11
  • What version of SharePoint and are you doing a 2010 or 2013 style workflow? May 20, 2016 at 13:06
  • Can someone tell how to do this in SharePoint Designer 2010 as suggested by user17734? Oct 27, 2017 at 10:26
  • in a 2010 workflow there is no 'FIND' Action i.e. this is not possible: then Find substring in string (Output to Variable: index1) Use a 2013 workflow instead to achieve this
    – Tally
    Mar 26, 2018 at 11:36

3 Answers 3

7

Try this:

1) Find substring in string in which:

  • substring is just the pipe | character
  • string is your metadatafield_0 field
  • output: index1

2) Extract substring from string with length in which:

  • substring is your metadata_0 field from the current item
  • starting location is 0
  • end is the output of the first step (index1)
  • output: substring1

Now log substring1. In my case this results exactly in all characters in front of the pipe character:)

3
  • 7
    I'm unable to find the action "Find substring in string". Is this a default action in SharePoint 2010 (Foundation)?
    – TempaC
    Sep 24, 2013 at 14:56
  • Neat- Just done this as a 2013 workflow updating title on a lookup list with a MMS column Dec 15, 2014 at 18:15
  • 3
    @TempaC I believe this is only available with SP 2013 Workflows.
    – TigerBear
    Jan 28, 2016 at 20:46
7
  • Find substring in string
    enter image description here
    Substring= |
    string=1 Year|5ff55ee4-5a60-2132-bc02-bbfdd9f190ab

    here you will get the index of "|"

  • Now pass that index in Extract string from start of string enter image description here

    replace 0 with your index number, i.e. variable:index1

    string=1 Year|5ff55ee4-5a60-2132-bc02-bbfdd9f190ab

    enter image description here

so you will get your output in variable:substring2 is 1 Year

substring is just the pipe | character string is your metadatafield_0 field output: index1

2
  • 1
    How can we do the same thing in sharepoint designer 2010 ? Apr 5, 2017 at 6:35
  • You might just need to download Sharepoint Designer 2013. In SPD 2013 you can also create/modify 2010 workflows. I use SPD 2013 but 95% of the workflows I use are using the 2010 'architecture'.
    – Tally
    Mar 26, 2018 at 11:39
3

In Sharepoint 2013 workflow:

1- Find the index of pipe "|" and save it to a variable.

2- Use an action called "Extract Substring from String from Index with Length".

3- Set copy from to be one of your original strings "1 Year|5ff55ee4-5a60-2132-bc02-bbfdd9f190ab" or "3 Months|b553caa2-fww7-4c7f-b84e-22788d26386a".

4- Set copy starting at to be 0.

5- Set for (length) to be the pipe index variable.

The output will be the part of the original string preceding the pip.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.