Extracting part of current URL and adding it as variable into script
Forum rules
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Extracting part of current URL and adding it as variable into script
Hello,
I'm fairly new to iMacros and trying to create a script to automatically create and complete a ticket in SalesForce. I'm able to get the actual ticket created, and I'm able to get that ticket closed, but I'm also required to have a support activity on the ticket. This requires clicking a button "New Support Activity." That when I click on the button, the result in iMacros includes part of the URL for the ticket. For example, if the ticket is at:
http://salesforce.com/500e0001X0cO?srPos=0&srKp=500
Clicking the button in iMacros results in:
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_500e0001X0cO_00N320002ChTK ATTR=NAME:new_support_activity
Every time I try to do this, the result is exactly the same, except for that 500e0001X0cO portion. I know I can use !URLCURRENT to extract the current URL, but is there a way to parse that URL to grab everything between "http://salesforce.com/" and "?" and turn that into a variable to change my line to read something like:
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_VARIABLE1_00N320002ChTK ATTR=NAME:new_support_activity
If I can get this part figured out, my life will be much easier!
I'm fairly new to iMacros and trying to create a script to automatically create and complete a ticket in SalesForce. I'm able to get the actual ticket created, and I'm able to get that ticket closed, but I'm also required to have a support activity on the ticket. This requires clicking a button "New Support Activity." That when I click on the button, the result in iMacros includes part of the URL for the ticket. For example, if the ticket is at:
http://salesforce.com/500e0001X0cO?srPos=0&srKp=500
Clicking the button in iMacros results in:
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_500e0001X0cO_00N320002ChTK ATTR=NAME:new_support_activity
Every time I try to do this, the result is exactly the same, except for that 500e0001X0cO portion. I know I can use !URLCURRENT to extract the current URL, but is there a way to parse that URL to grab everything between "http://salesforce.com/" and "?" and turn that into a variable to change my line to read something like:
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_VARIABLE1_00N320002ChTK ATTR=NAME:new_support_activity
If I can get this part figured out, my life will be much easier!
Re: Extracting part of current URL and adding it as variable into script
CIM...! (... For me to have a look..., read my Sig...)Chris3460 wrote: ↑Mon Mar 11, 2019 3:10 pmHello,
I'm fairly new to iMacros and trying to create a script to automatically create and complete a ticket in SalesForce. I'm able to get the actual ticket created, and I'm able to get that ticket closed, but I'm also required to have a support activity on the ticket. This requires clicking a button "New Support Activity." That when I click on the button, the result in iMacros includes part of the URL for the ticket. For example, if the ticket is at:
http://salesforce.com/500e0001X0cO?srPos=0&srKp=500
Clicking the button in iMacros results in:
Every time I try to do this, the result is exactly the same, except for that 500e0001X0cO portion. I know I can use !URLCURRENT to extract the current URL, but is there a way to parse that URL to grab everything between "http://salesforce.com/" and "?" and turn that into a variable to change my line to read something like:Code: Select all
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_500e0001X0cO_00N320002ChTK ATTR=NAME:new_support_activity
If I can get this part figured out, my life will be much easier!Code: Select all
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_VARIABLE1_00N320002ChTK ATTR=NAME:new_support_activity
Wondering what your Thread has "specific" with 'iMacros for FF' if you don't even mention your FCI...?
Try to select the/a "correct" Sub-Forum next time you'll open a Thread... (Would have been the 'General' or 'Data Extraction' Sub-Forum(s) for this one..., but no need to open a Duplicate now...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: Extracting part of current URL and adding it as variable into script
chivracq wrote: ↑Mon Mar 11, 2019 3:21 pmCIM...! (... For me to have a look..., read my Sig...)Chris3460 wrote: ↑Mon Mar 11, 2019 3:10 pmHello,
I'm fairly new to iMacros and trying to create a script to automatically create and complete a ticket in SalesForce. I'm able to get the actual ticket created, and I'm able to get that ticket closed, but I'm also required to have a support activity on the ticket. This requires clicking a button "New Support Activity." That when I click on the button, the result in iMacros includes part of the URL for the ticket. For example, if the ticket is at:
http://salesforce.com/500e0001X0cO?srPos=0&srKp=500
Clicking the button in iMacros results in:
Every time I try to do this, the result is exactly the same, except for that 500e0001X0cO portion. I know I can use !URLCURRENT to extract the current URL, but is there a way to parse that URL to grab everything between "http://salesforce.com/" and "?" and turn that into a variable to change my line to read something like:Code: Select all
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_500e0001X0cO_00N320002ChTK ATTR=NAME:new_support_activity
If I can get this part figured out, my life will be much easier!Code: Select all
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_VARIABLE1_00N320002ChTK ATTR=NAME:new_support_activity
Wondering what your Thread has "specific" with 'iMacros for FF' if you don't even mention your FCI...?
Try to select the/a "correct" Sub-Forum next time you'll open a Thread... (Would have been the 'General' or 'Data Extraction' Sub-Forum(s) for this one..., but no need to open a Duplicate now...)
Yeah, sorry. Literally my first post here, so pardon my not knowing what I'm doing. I posted in the FF forum because that's the version I'm using.
iMacros 10.0.2.1450
Firefox 65.0.2
Windows 7 Pro (Version 6.1 Build 7601; SP1)
Re: Extracting part of current URL and adding it as variable into script
OK, FCI mentioned, good...!Chris3460 wrote: ↑Mon Mar 11, 2019 3:40 pmYeah, sorry. Literally my first post here, so pardon my not knowing what I'm doing. I posted in the FF forum because that's the version I'm using.
Code: Select all
iMacros 10.0.2.1450 Firefox 65.0.2 Windows 7 Pro (Version 6.1 Build 7601; SP1)
Hum, 'Free' or 'PE' is still missing about your iMacros for FF Version...? (Would play a role for the Var Name...)
(And when posting/replying, you don't need to quote yourself again, that doesn't really help for "Readability" of the Thread...)
Then OK, to answer your Qt, yep, fairly easy to achieve, by using 'EVAL()' and "some" JavaScript String Manipulation Method(s), several ways possible, like 'replace()' + 'split()', for example, or 'split()' x2...
I would go for 'split()' x2 myself which I would find more "reliable" and more flexible than the 'replace()', as I'm a bit "surprised" btw by the "http" (and no "https") in the URL, and a 'split()' already on the "first part" would handle both Cases together ("http" + "https").
I let you "sweat" a little bit to try to find out the/a Solution by yourself and I'll post 1 or 2 Solution(s) a bit later on if you don't come out by yourself...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: Extracting part of current URL and adding it as variable into script
More apologies. Just clicked "quote" to quote you. It's the free version. And the URL isn't really the URL, so don't be too surprised by the http vs https part. And I thank you for your assistance.chivracq wrote: ↑Mon Mar 11, 2019 4:01 pm
OK, FCI mentioned, good...!
Hum, 'Free' or 'PE' is still missing about your iMacros for FF Version...? (Would play a role for the Var Name...)
(And when posting/replying, you don't need to quote yourself again, that doesn't really help for "Readability" of the Thread...)
Then OK, to answer your Qt, yep, fairly easy to achieve, by using 'EVAL()' and "some" JavaScript String Manipulation Method(s), several ways possible, like 'replace()' + 'split()', for example, or 'split()' x2...
I would go for 'split()' x2 myself which I would find more "reliable" and more flexible than the 'replace()', as I'm a bit "surprised" btw by the "http" (and no "https") in the URL, and a 'split()' already on the "first part" would handle both Cases together ("http" + "https").
I let you "sweat" a little bit to try to find out the/a Solution by yourself and I'll post 1 or 2 Solution(s) a bit later on if you don't come out by yourself...
Re: Extracting part of current URL and adding it as variable into script
Yeah, don't worry... Now, do your "Homework" and post your Solution...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: Extracting part of current URL and adding it as variable into script
From the look of it, I can't do this with the free version. For reference, I started playing with another post of yours that I found. Not sure if I even formatted this remotely correctly, but I threw this in:
When I ran it, I get:
So yeah, it looks like this is a no go from the free version.
Code: Select all
SET !VAR1 {{!URLCURRENT}}
SET TICKET EVAL ("var s=\"((VAR1))\";s.split(\"/\", 4);")
Code: Select all
FreewareLimit: Freeware version limit exceeded: user defined variables not allowed. Maximum number of variables is 3, line: 2
Re: Extracting part of current URL and adding it as variable into script
[quote=Chris3460 post_id=81785 time=1552323490 user_id=34075]
From the look of it, I can't do this with the free version. For reference, I started playing with another post of yours that I found. Not sure if I even formatted this remotely correctly, but I threw this in:
[code]SET !VAR1 {{!URLCURRENT}}
SET TICKET EVAL ("var s=\"((VAR1))\";s.split(\"/\", 4);")[/code]
When I ran it, I get:
[code]FreewareLimit: Freeware version limit exceeded: user defined variables not allowed. Maximum number of variables is 3, line: 2[/code]
So yeah, it looks like this is a no go from the free version.
[/quote]
Okay..., that's a "start", and you are making several "Mistakes"...
But yep you can "do it" with the 'Free' Version...
1- The Limitation with the 'Free' Version for Vars is that you can only use the 3x '!VAR[1-3]' as a Name for your Vars, you cannot use 'User defined Vars', and your "TICKET" would be a 'User defined Var'.
2- The Name of '!VAR1' is "!VAR1" and not "VAR1", the '!' belongs to that Name...
3- Referencing Vars is done with Double Curly Brackets => "{{" + "}}" and not with Brackets => "((" + "))"...
4- The Syntax you are using for 'split()' with "s.split(\"Some_String\", n)" will return the n first Splits, => in your "Case" with "n=4", "s.split(\"/\", 4)" will return "http:,,salesforce.com,500e0001X0cO?srPos=0&srKp=500", which is not what you want...!
The Syntax you need to use is "s.split(\"Some_String\")[i]", where 'i' is the Index Number for each 'split()' Element, starting at 'i=0' for the first Element (which would give the same Result like "s.split(\"Some_String\", 1)" then)...
5- Hum, and be "careful" with the Space in "EVAL (...", I think iMacros for FF doesn't mind, but there is/was one Version that "didn't like" that extra Space...
OK, back to "Homework", ah-ah...!
Hum, "sorry" for the "[quote]" and "[code]" parts, I had to disable BBCode in this Post because of the "[i]" that gets interpreted and displayed as /Italic/...
From the look of it, I can't do this with the free version. For reference, I started playing with another post of yours that I found. Not sure if I even formatted this remotely correctly, but I threw this in:
[code]SET !VAR1 {{!URLCURRENT}}
SET TICKET EVAL ("var s=\"((VAR1))\";s.split(\"/\", 4);")[/code]
When I ran it, I get:
[code]FreewareLimit: Freeware version limit exceeded: user defined variables not allowed. Maximum number of variables is 3, line: 2[/code]
So yeah, it looks like this is a no go from the free version.
[/quote]
Okay..., that's a "start", and you are making several "Mistakes"...
But yep you can "do it" with the 'Free' Version...
1- The Limitation with the 'Free' Version for Vars is that you can only use the 3x '!VAR[1-3]' as a Name for your Vars, you cannot use 'User defined Vars', and your "TICKET" would be a 'User defined Var'.
2- The Name of '!VAR1' is "!VAR1" and not "VAR1", the '!' belongs to that Name...
3- Referencing Vars is done with Double Curly Brackets => "{{" + "}}" and not with Brackets => "((" + "))"...
4- The Syntax you are using for 'split()' with "s.split(\"Some_String\", n)" will return the n first Splits, => in your "Case" with "n=4", "s.split(\"/\", 4)" will return "http:,,salesforce.com,500e0001X0cO?srPos=0&srKp=500", which is not what you want...!
The Syntax you need to use is "s.split(\"Some_String\")[i]", where 'i' is the Index Number for each 'split()' Element, starting at 'i=0' for the first Element (which would give the same Result like "s.split(\"Some_String\", 1)" then)...
5- Hum, and be "careful" with the Space in "EVAL (...", I think iMacros for FF doesn't mind, but there is/was one Version that "didn't like" that extra Space...
OK, back to "Homework", ah-ah...!
Hum, "sorry" for the "[quote]" and "[code]" parts, I had to disable BBCode in this Post because of the "[i]" that gets interpreted and displayed as /Italic/...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: Extracting part of current URL and adding it as variable into script
Hum, and I don't know which "other post of mine" you were using as Example, but it was not "the best one" and must be from several years ago, 3-4-5 I think, that's a "very old" Syntax I was using indeed when I had started using 'EVAL()' + 'split()', and which indeed mostly only worked when you only need to keep the first part of the 'split()'...
If you search my Posts on "eval+double+split", you should find much "better" Examples with nearly the exact Solution you need in your Case, I must have posted dozens of Examples already...
If you search my Posts on "eval+double+split", you should find much "better" Examples with nearly the exact Solution you need in your Case, I must have posted dozens of Examples already...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: Extracting part of current URL and adding it as variable into script
Alright, so I'm getting somewhere!!! First, I was wrong in my initial post. My initial URL format is:
http://salesforce.com/500e0001X0cO
All I need to remove is the "http://salesforce.com/" portion of the URL. I was able to accomplish that with:
With that, the prompt displayed
Now I just need to figure out how to change that to get that to display in the next line. I'm not sure how to format the line here, or if I just need to create a new variable, so any guidance would be great. I tried:
Which you'll probably look at and think "HUH?" but I really don't have a clue here.
http://salesforce.com/500e0001X0cO
All I need to remove is the "http://salesforce.com/" portion of the URL. I was able to accomplish that with:
Code: Select all
SET !VAR1 EVAL("var parts = \"{{!URLCURRENT}}\".split(\"/\"); parts[parts.length-1];")
PROMPT {{!VAR1}}
Code: Select all
500e0001X0cO
Code: Select all
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_!VAR1_00N320002ChTK ATTR=NAME:new_support_activity
Re: Extracting part of current URL and adding it as variable into script
And I figured it out!
Code: Select all
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_{{!VAR1}}_00N320002ChTK ATTR=NAME:new_support_activity
Re: Extracting part of current URL and adding it as variable into script
Chris3460 wrote: ↑Tue Mar 12, 2019 5:50 pmAlright, so I'm getting somewhere!!! First, I was wrong in my initial post. My initial URL format is:
http://salesforce.com/500e0001X0cO
All I need to remove is the "http://salesforce.com/" portion of the URL. I was able to accomplish that with:
With that, the prompt displayedCode: Select all
SET !VAR1 EVAL("var parts = \"{{!URLCURRENT}}\".split(\"/\"); parts[parts.length-1];") PROMPT {{!VAR1}}
Now I just need to figure out how to change that to get that to display in the next line. I'm not sure how to format the line here, or if I just need to create a new variable, so any guidance would be great. I tried:Code: Select all
500e0001X0cO
Which you'll probably look at and think "HUH?" but I really don't have a clue here.Code: Select all
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_!VAR1_00N320002ChTK ATTR=NAME:new_support_activity
Yep-yep-yep...!, very good...!Chris3460 wrote: ↑Tue Mar 12, 2019 5:57 pmAnd I figured it out!
Code: Select all
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:massActionForm_{{!VAR1}}_00N320002ChTK ATTR=NAME:new_support_activity
And you get a 9/10 for your Homework...!!
And I had already explained about '!VAR1' for the 'set' Functionality and '{{!VAR1}}' for the 'get' Functionality...
OK, now, your 'EVAL()' works but it can be "improved"/simplified a bit, and made more "robust" as I am "afraid" you might still get "Cases" where the part with the '?srPos=0&srKp=500' Parameters in the URL might still be present, and your 'EVAL()' won't work then, so you might still need the 2nd 'split()', "just to make sure"...
First I would adapt your:
Code: Select all
SET !VAR1 EVAL("var parts = \"{{!URLCURRENT}}\".split(\"/\"); parts[parts.length-1];")
PROMPT {{!VAR1}}
Code: Select all
SET !VAR1 EVAL("var u='{{!URLCURRENT}}'; var x,y,z; x=u.split('/'); y=x.length; z=x[y-1]; z;")
PROMPT URL:<SP>_{{!URLCURRENT}}_<BR>VAR1:<SP>_{{!VAR1}}_
Using the 'length' Property of the 'split()' Array to dynamically compute the Index is clever and can be useful in some Cases but a bit "Overkill" in your Case I think, and I think I would myself have hard-coded the Index. But as your 'split()' is on the '/' and there are always several '/' in an URL, I would have also chosen to lower the Index by stg like:
Code: Select all
SET !VAR1 EVAL("var u='{{!URLCURRENT}}'; var x,y,z; x=u.split('.com/'); z=x[1]; z;")
PROMPT URL:<SP>_{{!URLCURRENT}}_<BR>VAR1:<SP>_{{!VAR1}}_
Code: Select all
SET !VAR1 EVAL("var u='{{!URLCURRENT}}'; var x,y,z; x=u.split('.com/'); y=x[1].split('?'); z=y[0]; z;")
PROMPT URL:<SP>_{{!URLCURRENT}}_<BR>VAR1:<SP>_{{!VAR1}}_
(I didn't test any of those Statements, so I hope I didn't make any Typo... )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...