Dear All
We are facing an issue if I add '&' symbol in a text field while submitting a web form. if we are not adding the special character it works fine.
XML parsing is a issue I feel, even the '&' is changing to <varSetName>test&test</varSetName>. Not sure what is the issue, Please help me.
Below is the error while submitting,
We have found the script which is causing the issue.
Script:
var insertxml ="<Data_Collection xtkschema=\"xxx:Data_Collection\" Salutation= \"" + ctx.vars.varSalutation +"\" FIRST_NAME= \"" + ctx.vars.varFirstname +"\" LAST_NAME= \"" + ctx.vars.varLastname +"\" EMAIL= \"" + ctx.vars.varEmail +"\" PHONE= \"" + ctx.vars.varTelephone +"\" Creation_Date=\""+ formatDate(new Date(),'%4Y-%2M-%2D %2H:%2N:%2S') +"\" Creation_Date_2=\""+ formatDate(getCurrentDate(),"%2D.%2M.%4Y") +"\" SetName= \"" + ctx.vars.varSetName +"\" Preis= \"" + ctx.vars.varPreis +"\" GueltigBis= \"" + ctx.vars.varGueltigBis +"\" _operation=\"insert\"></Data_Collection>";
xtk.session.Write(insertxml);
Error Message:
Unterminated entity reference, 'test' XML-110018 Error while parsing XML string '<__sessiontoken xsi:type='xsd:string'><' SOP-330011 Error while executing the method 'Write' of service 'xtk:persist|xtk:session'.
Please let me know if you need any details.
Thanks in advance
Ukender
Solved! Go to Solution.
Views
Replies
Total Likes
Hello @ukender
Try this code.
var creationDate=formatDate(new Date(),'%4Y-%2M-%2D %2H:%2N:%2S');
var creationDate2=formatDate(getCurrentDate(),"%2D.%2M.%4Y");
var insertxml ="<Prospects_Data_Collection xtkschema='xxx:Prospects_Data_Collection' Salutation={ctx.vars.varSalutation} FIRST_NAME={ctx.vars.varFirstname} LAST_NAME={ctx.vars.varLastname} EMAIL={ctx.vars.varEmail} PHONE={ctx.vars.varTelephone} Creation_Date={creationDate} Creation_Date_2={creationDate2} SetName={ctx.vars.varSetName} Preis={ctx.vars.varPreis} GueltigBis={ctx.vars.varGueltigBis} _operation= 'insert' > <Product_interest Kobold={ctx.vars.varKobold} Bodenstaubsauger={ctx.vars.varBodenstaubsauge} Handstaubsauger={ctx.vars.varHandstaubsauger} Saugroboter200={ctx.vars.varSaugroboter200} Akkusauger={ctx.vars.varAkkusauger} Saugwischer={ctx.vars.varSaugwischer} Automatik_Elektroburste={ctx.vars.varAutomatik_Elektroburste} ContactEvents={ctx.vars.varEvents} Hartbodenduse={ctx.vars.varHartbodenduse} Fensterreiniger={ctx.vars.varFensterreiniger} Polsterburste={ctx.vars.varPolsterburste} Softduse={ctx.vars.varSoftduse} Flexoduse={ctx.vars.varFlexoduse} Teppichfrischer={ctx.vars.varTeppichfrischer} Matratzenreinigung={ctx.vars.varMatratzenreinigung} Varioduse={ctx.vars.varVarioduse} Elektrosaugschlauch={ctx.vars.varElektrosaugschlauch} Akku_Staubsauger={ctx.vars.varAkku_Staubsauger} Saugroboter300={ctx.vars.varSaugroboter300}> </Product_interest> <address STREET={ctx.vars.varStreet} HNUM={ctx.vars.varHousenum} POST_CODE={ctx.vars.varPostalcode} CITY={ctx.vars.varCity} STORE={ctx.vars.varStorename} VORWERK_EMAIL={ctx.vars.varStoreEmail}> </address> <Permissions ContactKobold={ctx.vars.varContactKobold} ContactKoboldBetr={ctx.vars.varContactKoboldBetr} Privacy_Accept={ctx.vars.varAccept}</Permissions> </Prospects_Data_Collection>";
xtk.session.Write(insertxml);
Let me know if that works.
Views
Replies
Total Likes
Hello @ukender
Try this code.
var creationDate=formatDate(new Date(),'%4Y-%2M-%2D %2H:%2N:%2S');
var creationDate2=formatDate(getCurrentDate(),"%2D.%2M.%4Y");
var insertxml ="<Prospects_Data_Collection xtkschema='xxx:Prospects_Data_Collection' Salutation={ctx.vars.varSalutation} FIRST_NAME={ctx.vars.varFirstname} LAST_NAME={ctx.vars.varLastname} EMAIL={ctx.vars.varEmail} PHONE={ctx.vars.varTelephone} Creation_Date={creationDate} Creation_Date_2={creationDate2} SetName={ctx.vars.varSetName} Preis={ctx.vars.varPreis} GueltigBis={ctx.vars.varGueltigBis} _operation= 'insert' > <Product_interest Kobold={ctx.vars.varKobold} Bodenstaubsauger={ctx.vars.varBodenstaubsauge} Handstaubsauger={ctx.vars.varHandstaubsauger} Saugroboter200={ctx.vars.varSaugroboter200} Akkusauger={ctx.vars.varAkkusauger} Saugwischer={ctx.vars.varSaugwischer} Automatik_Elektroburste={ctx.vars.varAutomatik_Elektroburste} ContactEvents={ctx.vars.varEvents} Hartbodenduse={ctx.vars.varHartbodenduse} Fensterreiniger={ctx.vars.varFensterreiniger} Polsterburste={ctx.vars.varPolsterburste} Softduse={ctx.vars.varSoftduse} Flexoduse={ctx.vars.varFlexoduse} Teppichfrischer={ctx.vars.varTeppichfrischer} Matratzenreinigung={ctx.vars.varMatratzenreinigung} Varioduse={ctx.vars.varVarioduse} Elektrosaugschlauch={ctx.vars.varElektrosaugschlauch} Akku_Staubsauger={ctx.vars.varAkku_Staubsauger} Saugroboter300={ctx.vars.varSaugroboter300}> </Product_interest> <address STREET={ctx.vars.varStreet} HNUM={ctx.vars.varHousenum} POST_CODE={ctx.vars.varPostalcode} CITY={ctx.vars.varCity} STORE={ctx.vars.varStorename} VORWERK_EMAIL={ctx.vars.varStoreEmail}> </address> <Permissions ContactKobold={ctx.vars.varContactKobold} ContactKoboldBetr={ctx.vars.varContactKoboldBetr} Privacy_Accept={ctx.vars.varAccept}</Permissions> </Prospects_Data_Collection>";
xtk.session.Write(insertxml);
Let me know if that works.
Views
Replies
Total Likes
Hi @Deleted Account, Thanks a lot for the suggestion.. I have tried your suggestion but the below script but doesn't work for me. it failed in compilation.
The previous code works well, If I did not add '&' special characters in the text field. So could you please suggest me some workaround for why the '&' is not taking in the text field.
Tried Script:
var creationDate=formatDate(new Date(),'%4Y-%2M-%2D %2H:%2N:%2S');
var creationDate2=formatDate(getCurrentDate(),"%2D.%2M.%4Y");
var insertxml ="<Prospects_Data_Collection xtkschema="xxx:Prospects_Data_Collection" Salutation={ctx.vars.varSalutation} FIRST_NAME={ctx.vars.varFirstname} LAST_NAME={ctx.vars.varLastname} EMAIL={ctx.vars.varEmail} PHONE={ctx.vars.varTelephone} Creation_Date={creationDate} Creation_Date_2={creationDate2} SetName={ctx.vars.varSetName} Preis={ctx.vars.varPreis} GueltigBis={ctx.vars.varGueltigBis}_operation= "insert" /> <Product_interest Kobold={ctx.vars.varKobold} Bodenstaubsauger={ctx.vars.varBodenstaubsauge} Handstaubsauger={ctx.vars.varHandstaubsauger} Saugroboter200={ctx.vars.varSaugroboter200} Akkusauger={ctx.vars.varAkkusauger} Saugwischer={ctx.vars.varSaugwischer} Automatik_Elektroburste={ctx.vars.varAutomatik_Elektroburste} ContactEvents={ctx.vars.varEvents} Hartbodenduse={ctx.vars.varHartbodenduse} Fensterreiniger={ctx.vars.varFensterreiniger} Polsterburste={ctx.vars.varPolsterburste} Softduse={ctx.vars.varSoftduse} Flexoduse={ctx.vars.varFlexoduse} Teppichfrischer={ctx.vars.varTeppichfrischer} Matratzenreinigung={ctx.vars.varMatratzenreinigung} Varioduse={ctx.vars.varVarioduse} Elektrosaugschlauch={ctx.vars.varElektrosaugschlauch} Akku_Staubsauger={ctx.vars.varAkku_Staubsauger} Saugroboter300={ctx.vars.varSaugroboter300}> </Product_interest> <address STREET={ctx.vars.varStreet} HNUM={ctx.vars.varHousenum} POST_CODE={ctx.vars.varPostalcode} CITY={ctx.vars.varCity} STORE={ctx.vars.varStorename} VORWERK_EMAIL={ctx.vars.varStoreEmail}> </address> <Permissions ContactKobold={ctx.vars.varContactKobold} ContactKoboldBetr={ctx.vars.varContactKoboldBetr} Privacy_Accept={ctx.vars.varAccept}</Permissions> </Prospects_Data_Collection>";
xtk.session.Write(insertxml);
Error:
JST-310000 Error while compiling script 'webApp_Prospects_Data_Collection_New_17_06_2019__preview' line 2610: missing ; before statement (line='var insertxml ="<Prospects_Data_Collection xtkschema="xxx:Prospects_Data_Collection" Salutation={ctx.vars.varSalutation} FIRST_NAME={ctx.vars.varFirstname} LAST_NAME={ctx.vars.varLastname} EMAIL={ctx.vars.varEmail} PHONE={ctx.vars.varTelephone} Creation_Date={creationDate} Creation_Date_2={creationDate2} SetName={ctx.vars.varSetName} Preis={ctx.vars.varPreis} GueltigBis={ctx.vars.varGueltigBis}_operation= "insert" /> <Product_interest Kobold={ctx.vars.varKobold} Bodenstaubsauger={ctx.vars.varBo' token='xxx:Prospects_Data_Collection" Salutation={ctx.vars.varSalutation} FIRST_NAME={ctx.vars.varFirstname} LAST_NAME={ctx.vars.varLastname} EMAIL={ctx.vars.varEmail} PHONE={ctx.vars.varTelephone} Creation_Date={creationDate} Creation_Date_2={creationDate2} SetName={ctx.vars.varSetName} Preis={ctx.vars.varPreis} GueltigBis={ctx.vars.varGueltigBis}_operation= "insert" /> <Product_interest Kobold={ctx.vars.varKobold} Bodenstaubsauger={ctx.vars.varBodenstaubsauge} Handstaubsauger={ctx.vars.varHandstaubsauger} ').
SCR-160032 Javascript: error while compiling script 'webApp_Prospects_Data_Collection_New_17_06_2019__preview'.
Views
Replies
Total Likes
Views
Replies
Total Likes
Hi @Deleted Account, Yes Manoj I have verified, I have the semi colon where ever it is necessary.
I have tried to keep semi colon ; in each element end tag as well but it didn't give me the solution,
For example I have given the ; in </address> .
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies