How to leave only the GET parameter from the URL.(Power Automate Desktop)

08/07/2023

Japanese version.

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.

Overall Flow.

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.

ParameterValue
Text to parseURL to remove GET parameters.
Text to find?
Is regular expressionOFF
Start parsing at position0
First occurrence onlyON

Then use the second Parse text Action to find the position of the "#". (Anchor position).

The Variables produced is renamed PositionSharp.

ParameterValue
Text to parseURL to remove GET parameters.
Text to find#
Is regular expressionOFF
Start parsing at position0
First occurrence onlyON

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.

ParameterValue
First operand%PositionQuestion%
OperatorGreater then or equal to(>=)
Second operand0

Set up an additional If Action inside the If Action. This is for cases where there is no anchor ("#").

ParameterValue
First operand%PositionSharp%
OperatorGreater then or equal to(>=)
Second operand0

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.

ParameterValue
Original textURL to remove GET parameters.
Start indexCharacter position
Character position%PositionQuestion + 1%
LenghtNumber 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.

ParameterValue
Original textURL to remove GET parameters.
Start indexCharacter position
Character position%PositionQuestion + 1%
LenghtEnd 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.

Links

How to convert URL parameters (GET parameters) into Data table.

Tips(Power Automate Desktop)