`var shipaddress = salesOrder.getSubrecord('shippi...
# suitescript
g
var shipaddress = salesOrder.getSubrecord('shippingaddress')
   
shipaddress.setValue({
     
fieldId: 'addressee',
     
value: order.shippingAddress.name
   
})
b
should probably double check if the field on the address subrecord are set but the address field on sales order is not updated
thats a very common thing
g
yes, so how wouldl I solve tat?
b
i used to set the address text myself
but evidently there are some address synchronization fields like
enable_subrecord_to_parent_synchronization
that you can try making sure are set to the correct value
g
I would want that set as true, correct?
It looks like its getting overwritten by the customer's default info. But the orders address is set to custom
b
im assuming so, i usually just overwrite the address text with the correct value
g
Just in plain text. Even if i put in json as text should work tho... or is their a specific format... Still not saving
saving now 😉 Is there a way to format it that it will save properly so it can be mapped?
b
not sure what you are asking
g
Meaning, now the text shows up on the order. but I have another script that sets the warehouse based on the postal code. WOn't work for these orders
b
set the fields on the subrecord too
g
like this: var shipaddress = salesOrder.getSubrecord('shippingaddress')     try {       shipaddress.setValue({         fieldId: 'addressee',         value: order.shippingAddress.name       })       shipaddress.setValue({         fieldId: 'shipaddr1',         val
i am
b
i was under the impression that your subrecord fields were being set but the address text on the sales order was not
g
Hi @battk Thanks for all your help. The address is only setting the address text. I need the address to be set though. I have tried 2 other ways     
salesOrder.setValue('billaddressee', order.billingAddress.name)
    
salesOrder.setValue('billaddr1', order.billingAddress.address1)
    
salesOrder.setValue('billaddr2', order.billingAddress.address2)
    
salesOrder.setValue('billaddr3', order.billingAddress.address3)
    
salesOrder.setValue('billcity', order.billingAddress.city)
    
salesOrder.setValue('billstate', order.billingAddress.state)
    
salesOrder.setValue('billzip', order.billingAddress.zip)
    
salesOrder.setValue('billphone', order.billingAddress.phone)
and
var billaddress = salesOrder.getSubrecord('billingaddress')
    
try {
      
billaddress.setValue({
        
fieldId: 'addressee',
        
value: order.billingAddress.name
      
})
      
billaddress.setValue({
        
fieldId: 'billaddr1',
        
value: order.billingAddress.address1
      
})
      
billaddress.setValue({
        
fieldId: 'addr2',
        
value: order.billingAddress.address2
      
})
      
billaddress.setValue({
        
fieldId: 'addr3',
        
value: order.billingAddress.address3
      
})
      
billaddress.setValue({
        
fieldId: 'city',
        
value: order.billingAddress.city
      
})
      
billaddress.setValue({
        
fieldId: 'state',
        
value: order.billingAddress.state
      
})
      
billaddress.setValue({
        
fieldId: 'zip',
        
value: order.billingAddress.zip
      
})
      
billaddress.setValue({
        
fieldId: 'country',
        
value: order.billingAddress.country
      
})
      
billaddress.setValue({
        
fieldId: 'addrphone',
        
value: order.billingAddress.phone
      
}) //
    
} catch (err) {
      
log.debug('ERROR SAVING BILLING ADDRESS' + err.message)
    
}
    
//-----------------------------------
    
//WE NEED TO FIND WHERE TO SAVE THE EMAIL ADDRESS TO :)
    
// shipaddress.setValue({
    
//   fieldId: '',
    
//   value: order.shippingAddress.email
    
// })
    
try {
      
salesOrder.save({
        
//writes record back to database
        
ignoreMandatoryFields: true //set for testing in case you want to create a record without validating which can give errors
      
})
      
log.debug('new ID: ' + salesOrder.id)
      
var nte = record.create({
        
type: 'note',
        
isDynamic: true
      
})
      
nte.setValue({ fieldId: 'transaction', value: salesOrder.id })
      
nte.setValue({
        
fieldId: 'title',
        
value: 'Items not add to SO: ' + salesOrder.id
      
})
      
nte.setValue({ fieldId: 'note', value: itemNote })
      
var strNoteID = nte.save({
        
enableSourcing: true,
        
ignoreMandatoryFields: true
      
})
    
} catch (err) {
      
log.debug(
        
'ERROR when trying to save order. (PO: ' +
          
order.poNumber +
          
' ) Message: ' +
          
err.message
      
)
    
}
  
}
for both billing andn shipping but to no avail
b
set country first
g
THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I really appreciate all the time you've been giving me to help me learn the ropes
101 Views