UPDATED - since I was not clear in me expressions. Will try again:
I have a form with several inputs that are created dynamically like this:
<form id="tellafriend_form" method="post" action="landingpage.aspx">
<!-- static example -->
<input type="text" id="my_example" name="my_example" value="" />
<!-- dynamic part -->
<xsl:for-each select="something">
<xsl:variable name="publicationId" select="#id"/>
<input type="text" id="{$publicationId}" name="{$publicationId}" value="" />
</xsl:for-each>
</form>
When submitted how do I get the value from the input using xslt? I can get it from the static input field but not from the dynamic fields since I do not know there names/ids.
I know that all $publicationId will be an integer greater than 2000 but less than 4000. If needed they can easily be prefixed with some text (if numbers alone make a problem).
An XSLT solution would be preferred. Or using jQuery if that could do the trick (saw this, that may be another solution: Obtain form input fields using jQuery?).
BR. Anders
landingpage.aspx won't be able to identify the relevant POST values as you never know in advance the input element name.
This suggests you'd need to augment the name with some additional data which you do know in advance. That is, add in extra information to the name that you can check for later.
A good choice is to append the names in such a way that the receiving script is able to (automatically) interpret them as an array. This is then easier to deal with in the receiving script. One such way, dependent on what the receiving language/framework allows, is:
<form id="tellafriend_form" method="post" action="landingpage.aspx">
<!-- static example -->
<input type="text" id="my_example" name="my_example" value="" />
<!-- dynamic part -->
<xsl:for-each select="something">
<xsl:variable name="publicationId" select="#id"/>
<input type="text" id="{$publicationId}" name="publication[{$publicationId}]" value="" />
</xsl:for-each>
</form>
Try this and examine the publication value in the POST data. You may find this is an array or hashmap. For this to work you would need to use the correct representation for an array of data within a form as far as the receiving language is concerned.
Another option is to augment the input names with a known identifier and then, within the receiving script, check all POST field names for the relevant identifier. For example:
<form id="tellafriend_form" method="post" action="landingpage.aspx">
<!-- static example -->
<input type="text" id="my_example" name="my_example" value="" />
<!-- dynamic part -->
<xsl:for-each select="something">
<xsl:variable name="publicationId" select="#id"/>
<input type="text" id="{$publicationId}" name="publication{$publicationId}" value="" />
</xsl:for-each>
</form>
Iterate through all the received POST name:value pairs and check for those whose name begins with 'publication'.
For this to work you must choose a prepend value that does not occur within an actual publication ID. I'm assuming here that a publication ID is numeric, hence any meaningful non-numeric prepend value (such as 'publication') would be appropriate.
Related
We have website developers redesigning the whole site in Django, and these are questions from our website developers I don't have any real knowledge of how to answer, so I thought someone here might be able to help.
We ran into a few problems with the web to lead and having it map to Salesforce which I HOPE we resolved.
Here's the code snippet:
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <META> element to your page <HEAD>. -->
<!-- If necessary, please modify the charset parameter to specify the -->
<!-- character set of your HTML page. -->
<!-- ---------------------------------------------------------------------- -->
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <FORM> element to your page. -->
<!-- ---------------------------------------------------------------------- -->
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
<input type=hidden name="oid" value="SFDCidhere">
<input type=hidden name="retURL" value="http://">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: These fields are optional debugging elements. Please uncomment -->
<!-- these lines if you wish to test in debug mode. -->
<!-- <input type="hidden" name="debug" value=1> -->
<!-- <input type="hidden" name="debugEmail" -->
<!-- value="emailaddresshere"> -->
<!-- ---------------------------------------------------------------------- -->
<label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>
<label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>
<label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>
<label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br>
<label for="phone">Phone</label><input id="phone" maxlength="40" name="phone" size="20" type="text" /><br>
Subject:<textarea id="00N1600000EgFuw" name="00N1600000EgFuw" rows="3" type="text" wrap="soft"></textarea><br>
Contact me:<input id="00N1600000EvgRY" name="00N1600000EvgRY" type="checkbox" value="1" /><br>
newsletter:<input id="00N1600000EvgRd" name="00N1600000EvgRd" type="checkbox" value="1" /><br>
<input type="submit" name="submit">
</form>
That's what the web-to-lead from SFDC generates, and seems to work now.
However they have 2 questions I am not certain about and would love assistance with:
1) The specs for the new site require that the return page be the one the form was sent from (I.e., no redirection; we’re intending to do the equivalent of a “thanks” page as a pop-up onClick() — how is that accomplished through the API? I’d EXPECT that sending an empty retURL value should do it, but we just get back a blank page with a salesforce.com URL;
2) is it possible to customize the “name” parameter for the two checkbox fields (if not then we have to hack the entire form in the Django template without making it possible for Django to render the form natively since you can’t have a model form field name start with a digit…). This isn’t THAT problematic, but I’d like to know for future reference.
If anyone has any insight, I'd love to hear it and pass it along to them!
Many thanks.
Not sure your solution.
The common way that you could using the Partner WSDL or Enterprise WSDL to insert,update,upsert ,delete your data
Parnter WSDL:
not custom from your salesforce org, but it could be common way to get your data.
In python your could use this package
https://pypi.python.org/pypi/pyforce/1.4
And reference by this
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_partner.htm
Enterprise WSDL will show your salesforce org status (including field and object) . But one your objects or fields are changing that it might be error.
So i suggest using api to control the redirect function and the action.
My solution is as follows in an example
from captcha.fields import ReCaptchaField
from django.conf import settings
def set_field_html_name(cls, new_name):
"""
This creates wrapper around the normal widget rendering,
allowing for a custom field name (new_name).
"""
old_render = cls.widget.render
def _widget_render_wrapper(name, value, attrs=None):
return old_render(new_name, value, attrs)
cls.widget.render = _widget_render_wrapper
class WebToLeadForm(forms.Form):
# <keep all fields here>
# example field below
referred_by = forms.CharField(label="Referred By", required=False)
# The reCAPTCHA in this form uses keys from settings.
captcha = ReCaptchaField()
set_field_html_name(referred_by, settings.SF_REFERRED_BY)
settings.py
SF_REFERRED_BY = '00xxxxxxxxxxxx'
lets say I have this XML :
<myxml>
<Labels>
<Label>
<id>id1</id>
<value>abc</value>
</Label>
<Label>
<id>id2</id>
<value>def</value>
</Label>
<Label>
<id>id3</id>
<value>ghi</value>
</Label>
<Label>
<id>id4</id>
<value>jkl</value>
</Label>
<Label>
<id>id5</id>
<value>mno</value>
</Label>
</Labels>
</myxml>
And I would like to display the value "def" and "jkl".
I'm looking for the XPath expression that allow me to take the value of a label where the id is "id2".
I've tried with this :
<xsl:value-of disable-output-escaping="yes" select="Labels/Label[id = 'id2']/value"/>
but it's not working ...
Is there a way to do that ?
Thanks in advance for your answer,
Best regards
Have you tried adding the root to your xpath?
<xsl:value-of select="myxml/Labels/Label[id = 'id2']/value" />
Also, disable-output-escaping is typically unnecessary.
I need to filter my list based on selected dropdown value. I've created a DVWP for that and converted it into a dropdown. Now I'm following this post to fire events when dropdown value is selected but I just do not know where to change the code. I'm filtering the list based on years. I have an year list which stores year values and filters it accordingly when the dropdown is selected. I've modified it like this:
<xsl:otherwise>
<select name="ID" size="1" onchange="document.location.href='pageName.aspx?year=' + this.options[selectedIndex.value])">
<option selected="true" value="0">Choose One...</option>
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows" />
</xsl:call-template>
</select>
I've no idea of xslt and this isn't firing any event when i change the dropdown value. Please help me with this.
Update: The HTML I get:
<td valign="top">
<div WebPartID="9e0da2fd-21ea-417f-863d-6551d16e72a1" HasPers="false" id="WebPartWPQ3" width="100%" class="noindex" allowDelete="false" style="" >
<select name="ID" size="1" onchange="document.location.href='http://pageName.aspx?year=' + this.options[selectedIndex].value" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<option selected="" value="0">Choose One...</option>
<option>2009</option>
<option>2010</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
</select>
</div>
</td>
I'm somewhat doubtful that this is an XSLT issue. The script for the onchange handler in that tutorial seems to boil down to:
document.location.href='pageName.aspx?year=' + this.options[selectedIndex].value
Note that .value is outside the []. Could you give that a try? Is your browser reporting any JavaScript errors when you change the dropdown selection?
Now, according to this tutorial, you can filter a list by specifying query parameters named FilterField1, FilterValue1, etc, so could you try something like this:
document.location.href='pageName.aspx?FilterField1=ColumnName&FilterValue1='
+ this.options[selectedIndex].value + '&year=' + this.options[selectedIndex].value
Here you would replace "ColumnName" with the actual name of the column, as indicated in that tutorial. Could you try something like that?
I need a regex to match all self-closing <input /> tags which lacks a type attribute.
For example, I want to find these:
<input size="1" />
<input name="test" />
But not this:
<input type="radio" />
Please note, this should be adaptable for any single attribute. I am just using type here as an example.
FYI, I am performing a search across 1000s of .html files using AstroGrep.
You can assume that the attribute is well-formed, with equals sign and double quotes.
<input(?:\s+(?!type=)\w+="[^"]*")*\s*/>
That should work if AstroGrep's regex flavor isn't too exotic. I can't find an online reference for it.
I don't know what is AstroGrep, but if it has negative look-ahead, you could just do
(?!\<input(?:[[:space:]]+[a-zA-Z0-9_]+="[^"]*")*(?:[[:space:]]+type="[^"]*"))<input(?:[[:space:]]+[a-zA-Z0-9_]+="[^"]*")*[[:space:]]*/>
Without it, it is much more laborious.
Thank you for taking the time to look at my post.
I have an input tag that i need to have output-ed like so:
<input type="hidden" name="success_redirect" value="http://www.webpage.com?var1=${root/option1}&var2=${root/option2}" />
but i cant get that into my xslt document without it eventually rendering to
<input type="hidden" name="success_redirect" value="http://www.webpage.com?var1=$&var2=$" />
What do i put in the XSLT to allow me to get that value tag to output like i need it to?
Thanks!
Just use:
<input type="hidden" name="success_redirect"
value="http://www.webpage.com?var1=${{root/option1}}&var2=${{root/option2}}" />
Do note that if we want to output a '{' or a '}' in an attribute, we have to double them.
This is because these two characters have special meaning when used inside an attribute: they indicate the start and end of an AVT (attribute-value-template).
You can concatenate the parts:
<input type="hidden" name="success_redirect"
value="{concat('http://www.webpage.com?var1=${','root/option1}','&var2=${','root/option2}')}" />