Is it possible to create a custom address on a tra...
# suitescript
t
Is it possible to create a custom address on a transaction using a client on save or user event before submit? I keep going in circles through the documentation and the only way I can seem to get it to work is with an already existing record on an after submit, but this script needs to be on creation of a record. If anyone's uncovered the secret I would appreciate the help, i've been stuck on this for a while. headbang
a
Not sure if I understand the question clearly... Do you mean like a new shipping address while creating a new Sales Order? For that specific case, you may want to try to edit the customer record first to add the address. Then get the transaction record (current record) in Dynamic mode, and grab the new address from shiptoselect SELECT field.
Also, if the record is updated even AFTER-SUBMIT, to the user it looks real time - so what is driving the need to have on before-submit...
t
Yes, a custom address while creating a sales order. So it would be a one-time address that is saved on just the transaction, and would not be saved or pulled from the customer record.
a
I wouldn't be surprised if it's not possible, since addresses are subrecords attached to the parent record - so if the parent record doesn't exist yet (as in client save or UE beforesubmit on create), it can't attach it. agreed with @Ankur Sanghi that aftersubmit is likely your best bet
t
Fair point... ideally it would be a client script that updates based on a certain criteria as the order is being entered. Mainly because a change in address could change the tax nexus and tax amount, which affects the total order amount. Once it was working on a general trigger such as on save I was planning to change it to run on a field change function.
@Ankur Sanghi @amy The main issue is that the order amount can be changed, and if it's changed after submit then the amount that the amount that Solupay calculates an charges when the order is saved will be the wrong amount charged to a customer credit card.
a
@theglenjamin - interesting use case, but understandable. How is it handled currently on the UI? Wouldn't you run into the same problem?
t
In the UI it works fine, when you change the address or add a custom address the amount changes but it all happens before the record is saved. So the final amount has already been calculated before the order is submitted. Duplicating via a script while the order is still in edit mode is proving to be a challenge though, and I'm starting to wonder if it's just not supported at all. @Ankur Sanghi
a
I must be missing something here. In my account, there seems to be no 'ad hoc' address on a Sales Order. I must select a customer and then there is an option to add a new address. That new address, however, gets saved to the customer record. If that's the case, the approach of edit-saving the customer record to add a new address should help. I have a feeling that after adding a new address to customer, you will need to re-add the customer on the Sales Order, so the new address option becomes available in the Select field.
b
@theglenjamin I don't know if this would be a work around or not but our SuitePayments solution has an authorization tolerance feature built into it. This allows you to authorize the card upfront for a percentage more than the base order amount and allows you to charge the card for a lesser amount based on what the actual total comes out to me. For example, if it's a $100 order and you want to authorize the card for 10% more (as an example) than the base amount in order to cover shipping and tax differences, the card would initially get authorized for $110. Once the final amount is calculated it would capture and charge the card for the corrected amount of the order that can be equal to or less than the original preauthorized amount. in this example, equal to or less than the $110 figure.
t
@brendan-solupay That was the next thing I was going to look into, and should be a great work around. Thanks!
message has been deleted
@Ankur Sanghi There are three options for addresses in the UI. One is to select an already existing customer address, the second is to create a "new" address and save it back to the customer. The third one which I am trying to script is to create a "custom" address. This adds it just to the order but does not save it back to the customer.
b
the custom address select option is associated with fields like shipcountry or billaddr1
basically the normal address fields with ship or bill in front
set those fields to get your custom address that is stored on the sales order
a
was just browsing the release notes and saw this: "2019.1 Address Scripting Changes to Support Transaction Tax Calculations" - might be worth a read to make sure whatever script you write won't break with the new release
t
@battk That was it! I thought we needed to use the subrecord....but those fields still work for now. @amy I found that as well, thanks for the info. Thank you both for the help!
👍 1