1

I have a scenario where the input is read from csv and set the SOAP request values. I having issues when there is a XML list and the child values are populated based on the values in csv. If there are no values for Alternate email in csv should not be included in the request and if there is only value available , only one child has to be inside the For e.g

<Customer>
<EmailAddress>testemail@yahoo.com</EmailAddress>
<AlternateEmailList>
    <EmailAddress>altemail1@yahoo.com</EmailAddress>
    <EmailAddress>altemail1@yahoo.com</EmailAddress>
    <EmailAddress>altemail1@yahoo.com</EmailAddress>
</AlternateEmailList>
</Customer>

I tried to use one of the example from xml.feature to set the values using javascript function like this

    * def emailList = 
    """
function(){
  var emailAddress = '<EmailAddress>#(EmailAddress)</EmailAddress>';
  if(alternameEmailAddress1 !='' || alternameEmailAddress2 !='' ||alternameEmailAddress3 !='')
 {
    emailAddress = emailAddress+'<AlternameEmailAddressList>';
 }
 if(alternameEmailAddress1 !=''){
   emailAddress = emailAddress+<EmailAddress>#(alternateEmailAddress1)</EmailAddress>;
}
if(alternameEmailAddress2 !='' ){
   emailAddress = emailAddress+<EmailAddress>#(alternateEmailAddress1)</EmailAddress>;

}
if(alternameEmailAddress3 !=''){
   emailAddress = emailAddress+<EmailAddress>#(alternateEmailAddress1)</EmailAddress>;

} 
return emailAddress;
}
"""
 * set req /Envelope/Body/Customer = emailList

but when setting the request, the whole javascript function is set. How to achieve this.

Please ignore if any typo or syntax is there in the above function... I can't paste exact code here and hope you can understand what I'm trying to achieve

0 Answers0