Avatar

Level 3

Hi @manoj, 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&colon; error while compiling script 'webApp_Prospects_Data_Collection_New_17_06_2019__preview'.