I am retrieving the values from a SharePoint multiple choice item. To do that I am doing this:
This is working fine in that I am getting all the values but the flow is adding a comma at the end of the string, when there are no more values: e.g. Work Schedule, Compensation,
I'd like to omit the last comma: if there are no more values omit the comma
Is there a way to do this?
Thanks for any help.
use the following function on the string
Hi, Thanks so much for responding.
I can't figure out where to add the substring function. I've attached a screen shot of the 2 actions involved.
here are the 2 actions involved:
can you tell me where to put the substring function? I am obviously very new to all this but i did try to figure it out. The substring function does not appear anywhere in my expression list.
Hello again, I did figure out (I think) where to put the substring function but the last cooma is still there.
I must be doing something wrong. Do you have any suggestions?
There is a way to do what you want, which is basically remove the last character of a string with an expression like this:
substring(variables('TypeofChangeChoices'), 0, sub(length(variables('TypeofChangeChoices')), 1) )
If I may, I would suggest a different approach for future flows. Instead of appending to a string variable, instead use an array variable. Then if you need to use that array variable as a delimited string, you can use the join expression to give you the string representation with whatever delimiter you choose.
This expression can go into a compose action, like this:
You can then use this compose action as the dynamic content for any subsequent actions.
If I answered your question Accept it as a solution ✔️
If I helped you out, please give me some Kudos 👍
You'll need to add a Compose after you exit the Apply to each loop and add the substring code there. Use the variable as the text. Then the text without the trailing comma will be the output of the compose.
sorry to be so dense.
i added the compose action after the apply to each action but the only option i have is to enter "*Inputs".
Is that where you want me to enter the substring function, replacing "stringvariable" with "TypeofChangeChoices"?
I will keep trying...
When the inputs field comes up you should have access to the dynamic content dialog. You enter the formula in the expressions tab in that dialog.
I finally got this to work using this solution:
i used 2 compose actions. The second one contains this substring expression:
This worked perfectly. I can't take credit for this though as I found the solution in this post:
Thanks for trying to help me. I really appreciate it.
This is what the substring code is:
Please let me know if this helped you to resolve your issue.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
At the monthly call, connect with other leaders and find out how community makes your experience even better.
If you are a small business ISV/Reseller, share your thoughts with our research team.