How to leave only the GET parameter from the URL.(Power Automate Desktop)
This section describes how to remove non-GET parameters from URL.
This is the reverse of How to remove URL parameters.

Overall view of Flow

Robin(for copy and paste)
It can be copied and pasted into Power Automate Desktop.
SET Url TO $'''https://www.samurai-emblem.com/?v1=a&v2=b&v3=c#head'''
Text.ParseText.ParseForFirstOccurrence Text: Url TextToFind: $'''?''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> PositionQuestion
Text.ParseText.ParseForFirstOccurrence Text: Url TextToFind: $'''#''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> PositionSharp
IF PositionQuestion >= 0 THEN
IF PositionSharp >= 0 THEN
Text.GetSubtext.GetSubtext Text: Url CharacterPosition: PositionQuestion + 1 NumberOfChars: PositionSharp - PositionQuestion - 1 Subtext=> Subtext
ELSE
Text.GetSubtext.GetSubtextFrom Text: Url CharacterPosition: PositionQuestion + 1 Subtext=> Subtext
END
END
Flow creation steps
URL parameters begin with "?". This flow uses that rule.

The Parse text Action searches for the position of "?" position in the Parse text Action.
This action is set up one more time, so we change the name of the Variables produced to PositionQuestion.
Parameter | Value |
---|---|
Text to parse | URL to remove GET parameters. |
Text to find | ? |
Is regular expression | OFF |
Start parsing at position | 0 |
First occurrence only | ON |

Then use the second Parse text Action to find the position of the "#". (Anchor position).
The Variables produced is renamed PositionSharp.
Parameter | Value |
---|---|
Text to parse | URL to remove GET parameters. |
Text to find | # |
Is regular expression | OFF |
Start parsing at position | 0 |
First occurrence only | ON |

Next, Set up an If Action to control the URL parameter ("?") to avoid errors.
This If Action is not necessary in cases where the URL parameter("?") is not necessary in cases where the URL parameter("?") is always present.
Parameter | Value |
---|---|
First operand | %PositionQuestion% |
Operator | Greater then or equal to(>=) |
Second operand | 0 |

Set up an additional If Action inside the If Action. This is for cases where there is no anchor ("#").
Parameter | Value |
---|---|
First operand | %PositionSharp% |
Operator | Greater then or equal to(>=) |
Second operand | 0 |

The second If Action adds an Else Action to make it look like the one below.

Set up Get subtext Action in the second If Action.
Parameter | Value |
---|---|
Original text | URL to remove GET parameters. |
Start index | Character position |
Character position | %PositionQuestion + 1% |
Lenght | Number of chars |
Number of chars | %PositionSharp - PositionQuestion - 1% |

Set up Get subtext Action in Else Action as well.
The second one will automatically change the Variables produced name, so change it to the same (Subtext) as the first one.
Parameter | Value |
---|---|
Original text | URL to remove GET parameters. |
Start index | Character position |
Character position | %PositionQuestion + 1% |
Lenght | End of text |


Executing this flow will set the Variables produced(Subtext) of Get subtext Action to the URL with the GET parameter removed.
For those who want to learn Power Automate Desktop effectively
The information on this site is now available in an easy-to-read e-book format.
Or Kindle Unlimited (unlimited reading).

You willl discover how to about basic operations.
By the end of this book, you will be equipped with the knowledge you need to use Power Automate Desktop to streamline your workflow.
Discussion
New Comments
No comments yet. Be the first one!