Create two variables from parsed string - parsing

I'm trying to parse a string into two variables. The source is a SQL query that populates values for multiple checkboxes. The number of checkboxes varies base on the query results. The checkboxes are coded:
<input type="checkbox" name="Listname" value="#RecID#:#DistListName#" ID="ListName#ListID#">
Using code I found here, I remove the : separating RecID and DistListName with:
<cfset PreParseList = #form.Listname#>
<cfset ParseList = ListToArray(PreParseList, ":", false, true)>
The output of ParseList looks like this:
627 Corporate IT Desktop Team DL,629 Corporate IT Helpdesk Team DL,607 HMC Behavioral Health DL,257 Kauai Region HR
I need to create two variables, one for the RECID which can be 1 to 3 digits long, and one for the name. The RecID gets written to a junction table that controls what distribution lists a user would have access to. The name is just displayed on the confirmation page.
Is what I'm trying even possible, or should I look into a different way of passing the RecID and name?

<cfset recIds = []>
<cfset distListNames = []>
<cfloop list="#form.Listname#" index="checkboxValue">
<cfset arrayAppend(recIds, listFirst(checkboxValue, ':'))>
<cfset arrayAppend(distListNames, ListRest(checkboxValue, ':'))>
</cfloop>
should I look into a different way of passing the RecID and name?
It'd be logical to only set the value of checkbox to RecID, since "the name is just displayed on the confirmation page". Then you get a list of RecIDs from the form scope, ready to be used, for free. Is the confirmation page a CFM page? If so, couldn't you display the name(s) that by fetching from DB again by ID(s)?

Related

Looking to fill out most or all of the Fed Ex "Create Label" page using URL query string

Looking to create a shipment on www.fedex.com
But fill out most of the fields using a query string at the end of a URL.
Seems like this might not be possible, but need help figuring out how to know whether it is or not.
My "Create Labels" page has a URL ending in -- ?method=doInitialize&utype=null ,
or else sometimes ...
-- ?method=doEntry&link=1&locale=en_US&urlparams=us&sType=F
so it seems promising. Just not sure how to access the names of the required fields (Contact name, Address 1 and 2, etc ) besides guess and check.
Thanks!
--------- Destination Section Parameters Found
The query string parameters for the destination contact field are, at the time this answer was written :
toData.addressData.contactName
toData.addressData.addressLine1
toData.addressData.addressLine2
toData.addressData.zipPostalCode
toData.addressData.city
toData.addressData.stateProvinceCode
toData.addressData.phoneNumber
psdData.mpsRowDataList[0].weight
Of course, they need to be appended to the original URL using valid query string syntax and URL encoding.
--------- How Were These Found ?
These were each found using the page inspector. I found that it is important to cut through the noise by zeroing in on the exact field where the data needs to be entered, and opening up the page inspector to that location.
Right click (Win) or control click (Mac) > "inspect"
This will bring up the following text in the inspector. By trial and error, I discovered that the "name" fields correspond to the working query string parameters.
The part we are looking for :
This corresponds to the query string parameter ...
toData.addressData.addressLine1
... originally listed above.
--------- Unsolved Parameters
It's a mystery why this same rule doesn't apply in the same way to other values in the page, like service type (e.g. "Priority Overnight") or package type (e.g. "FedEx Box"). The following, for example, do not fill as expected, even when using the exact same "name" field from the page inspector.
psdData.mpsRowDataList[0].carriageValue
psdData.serviceType
psdData.packageType
billingData.referenceData.yourReference
Maybe it's a URL encoding issue? Anyway, hope this helps.

Thymeleaf replacing property variable with value from server side

I am trying to make UI by using Thymeleaf template engine. I have a property file, which contains list of messages for validations.
For example: I have a propery customer.collateral.allocated_amount=Entered amount is bigger than your available balance. Balance: {0}
Now this I wanna replace this {0} with value, which I get from server side from database. For example, I query from database and I get 500.50. And what I want to do now, is to display this propery with value. In this example, it would be: Entered amount is bigger than your available balance. Balance: 500.50
I tried to do this, but no luck:
<th class="right" th:inline="text">([[#customer.collateral.allocated_amount]], ${availableAmount})</th>
How could I do this?
Here are the steps you need to follow for a basic set-up to use Thymeleaf messages:
1) Let's assume you have a Thymeleaf template called customers.html.
2) Your properties file must therefore be called customers.properties, and it must be placed in the same directory as the customers.html template.
3) Let's assume your properties file contains this entry:
amountBiggerThanAvailable=Entered amount is bigger than your available balance. Balance: {0}
4) For the placeholder {0} I will assume you have a Java object called account which has a property called availableAmount and which you pass to Thymeleaf in the usual way (i.e. the same way you pass any other data to your Thymeleaf template). Of course, your version may be different.
Here, I will use a <div> for my example - but you can use whatever you want, of course:
5) Use the message in your template like this:
<div th:text="#{customers.amountBiggerThanAvailable(${account.availableAmount})}"></div>
Note that there is no actual content in the div (between the opening <div> and the closing </div>). All the Thymeleaf directives are attributes inside the opening <div>.
The above fragment will generate the following HTML in your web page:
<div>Entered amount is bigger than your available balance. Balance: 123.45</div>
Once you have got this far, there are various enhancement you can make. For example, you can also look into providing localized (translated) messages as described here.

Query string parameters are not working to slice the data after publishing report

I have created a report where I created one calculated column which holds the value of dynamic URL. It has ID as parameter and I want to slice the data based upon that after publishing. When I am publishing this report to powerbi.com and I am using this URL to filter out the data, it shows me all the data. The filters through URL is not working.
I just went through a blog and when publishing through query string parameter it says that it has a limitation that it doesn't work when it will be published to web. What does it mean?
Below is the calculated column:
https://app.powerbi.com/groups/ce347380-637d-4700-838f-f7b00294256c/reports/374c3b7b-18f0-46f6-b5ec-2c97cbb01611/ReportSection?filter=Append1/Append1[SIMPrjReqID] eq '"&Append1[SIMPrjReqID]&"'
where Append1 is table and SIMPrjReqID is a column on which I want to filter out the data dynamically.
Please advise!
it has a limitation that it doesn't work when it will be published to web. What does it mean?
This means that passing URL query string parameters to filter data works only when applied on the report's URL, as you see it in the browser's address bar when you open it in powerbi.com, and not on the URL that you get when you use Publish to web option to make it public:
This filter does not work, because you didn't specified the field name correctly:
?filter=Append1/Append1[SIMPrjReqID] eq '"&Append1[SIMPrjReqID]&"'
As noted in the official documentation, the filter is passed in this format URL?filter=Table/Field eq 'value', where Field is the name of the field. So your query string parameter should look like this:
?filter=Append1/SIMPrjReqID eq '"&Append1[SIMPrjReqID]&"'

Analyze Google Adwords

I am looking to connect online leads data in Salesforce with Google Adwords keywords. Is there any way to have following fields I can add in Lead.
Click Cost
Keyword
What you can do is to use the lead field "lead_source" on salesforce and set that it takes the query string parameter into that field.
If you use PHP It will like the following
<input type="hidden" id="lead_source" name="lead_source" value="<?php $_GET['url_source'] ?>"/>
Now, when you set the target URL on Adwords in you should employ the keyword replacement, using the same query string name.
http://www.example.com?url_source={keyword}
or put after url_source here whatever extra data you want (I put more than just the keyword). But I don't know of a reason to get the cost there, only the keyword.
The problem with this approach is that you can only take the keyword from URL if the user downloaded on the same landing page (if he navigates to another page, you lose the query string parameter). If you want to keep this information for a later conversion, you will have to store this data in a cookie. Try this project if you want to implement it:
https://github.com/dm-guy/utm-alternative

How to reference a string of text then hyperlink it to a url?

My problem is i need a bit of code to reference a tracking number eg 1193849302, and insert it into a url http://www.example.com/track=[tracking number], so that the [tracking number] is replaced by 1193849302
then to have showing only the tracking number which is hyperlinked to said URL, i.e. 1193849302 (hyperlinked)
Either in html or javascript I think most of the site is CSS based though
Is this possible?
Thanks in advance
Edit maybe i should explain what i want a bit better
I have a customer area on a retail website , which returns the customers parcels tracking number when despatched.
What i'm after is a way to turn this tracking number into a working hyperlink which when clicked opens a new window into the couriers website automatically pushing the tracking number into the url and tracking the parcel for them.
Does this sound possible??
Most languages have a String.replace function.
For example, in Javascript, use replace() for this. Note that it takes a regex as an argument, so the [] need to be escaped:
var str = "http://www.example.com/track=[tracking number]";
str = str.replace("\[tracking number\]", "1193849302");
use String.replace method
The replace() method searches a string for a specified value, or a regular expression, and returns a new string where the specified values are replaced.
var str="http://www.example.com/track=[tracking number]";
var n=str.replace("tracking number","1193849302");
You can find more informations at http://www.w3schools.com/jsref/jsref_replace.asp

Resources