cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP Customize Envelope

sdeng
New Contributor II

Do you have a sample for soap execute>customized envelope> foreach Function? What’s the language we should use in customized envelope?

1 ACCEPTED SOLUTION

stodoroska
New Contributor III

You can use Apache velocity to do foreach, if and etc.

Example:

<SOAP-ENV:Envelope
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ns1="urn:general_2015_2.transactions.webservices.netsuite.com"
    xmlns:ns2="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ns0="urn:messages_2015_2.platform.webservices.netsuite.com"
    xmlns:ns3="urn:core_2015_2.platform.webservices.netsuite.com"
    xmlns:ns4="urn:core_2015_2.platform.webservices.netsuite.com">
    <SOAP-ENV:Header>
        <ns0:applicationInfo>
            <ns0:applicationId>$Soap_Execute_applicationId</ns0:applicationId>
        </ns0:applicationInfo>
        <ns0:passport>
            <ns4:email>$Soap_Execute_Passport_email</ns4:email>
            <ns4:password>$Soap_Execute_Passport_password</ns4:password>
            <ns4:account>$Soap_Execute_Passport_account</ns4:account>
        </ns0:passport>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns0:add>
            <ns0:record ns2:type="$record.journalEntry">
                <ns1:customForm internalId="$record.customForm.internalId" />
                <ns1:postingPeriod internalId="$record.postingPeriod.internalId"/>
                <ns1:tranDate>$record.tranDate</ns1:tranDate>
                <ns1:tranId>$record.tranId</ns1:tranId>
                <ns1:createdFrom internalId="$record.createdFrom.internalId"/>
                <ns1:subsidiary internalId="$record.subsidiary.internalId"/>
                <ns1:reversalDate>$record.reversalDate</ns1:reversalDate>
                <ns1:reversalDefer>$record.reversalDefer</ns1:reversalDefer>
                <ns1:approved>$record.approved</ns1:approved>
                <ns1:memo>$record.memo</ns1:memo>
                <ns1:customFieldList>
                    <ns3:customField ns3:scriptId="$record.batchId.scriptId" ns3:internalId="$record.batchId.intId" ns2:type="$record.batchId.type">
                        <ns3:value>$record.custbody_batch_id</ns3:value>
                    </ns3:customField>
                    <ns3:customField ns3:scriptId="$record.customFieldList.customField[0].scriptId" ns:internalId="$record.customFieldList.customField[0].internalId" ns2:type="ns3:SelectCustomFieldRef">
                        <ns3:value>$record.customFieldList.customField[0].value.internalId</ns3:value>
                    </ns3:customField>
                </ns1:customFieldList>
                <ns1:lineList>
                #set ($a = -1)
                #foreach($line in $record.lineList.line)
                    <ns1:line>
                    #set ($a = $a+1)
                        <ns1:account internalId="#foreach($account in $record.lineList.line[$a].account)$account#end"></ns1:account>
                        <ns1:debit>$record.lineList.line[$a].debit</ns1:debit>
                        <ns1:credit>$record.lineList.line[$a].credit</ns1:credit>
                        <ns1:memo>$record.lineList.line[$a].memo</ns1:memo>
                        <ns1:custbody_custom_jnl_id>$record.lineList.line[$a].custbody_custom_jnl_id</ns1:custbody_custom_jnl_id>
                        <ns1:department externalId="#foreach($department in $record.lineList.line[$a].department)$department#end"/>
                        <ns1:class internalId="#foreach($class in $record.lineList.line[$a].class)$class#end"/>
                        <ns1:customFieldList>
                            <ns3:customField ns3:scriptId="$record.product.scriptId" ns3:internalId="$record.product.intId" ns2:type="$record.product.type">
                                <ns3:value internalId="#foreach($value in $record.lineList.line[$a].customFieldList.customField[0].value)$value#end"></ns3:value>
                            </ns3:customField>
                        </ns1:customFieldList>
                    </ns1:line>#end 
                </ns1:lineList>
            </ns0:record>
        </ns0:add>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

View solution in original post

5 REPLIES 5

I am also looking for help on the Mapper snap prior to the Soap Execute. I need to hardcode a value but it needs to be for each record, not just once. Does anyone have advice?