cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Script to clear Quote's "Billing and Shipping" tab

Sergey_L
Participant
0 Likes
577

Hello,

Below is an excerpt of my script attempt to clear the customer entries (Bill To, Ship To, End User) on a quote. (For the rest, just replace "BillTo" with "ShipTo" and then with "EndUser")

Not only does this seem unnecessarily long, but the fields don't stay cleared - they are re-populated with the original info. It seems like a contact in the address book is selected, and clearing all these fields without resetting the selected contact doesn't actually do anything.

How do I remove the 3 customer selections on a quote? I'm hoping for something like "Quote.BillToCustomer = None"...

Quote.BillToCustomer.Active = False
Quote.BillToCustomer.Address1 = ''
Quote.BillToCustomer.Address2 = ''
Quote.BillToCustomer.BusinessFax = ''
Quote.BillToCustomer.BusinessPhone = ''
Quote.BillToCustomer.City = ''
Quote.BillToCustomer.CompanyName = ''
Quote.BillToCustomer.CountryAbbreviation = ''
Quote.BillToCustomer.CrmAccountId = ''
Quote.BillToCustomer.CrmContactId = ''
Quote.BillToCustomer.CustomerCode = ''
Quote.BillToCustomer.CustomerType = ''
Quote.BillToCustomer.Email = ''
Quote.BillToCustomer.FirstName = ''
Quote.BillToCustomer.LastName = ''
Quote.BillToCustomer.OwnerName = ''
Quote.BillToCustomer.PrimaryIndustry = ''
Quote.BillToCustomer.Province = ''
Quote.BillToCustomer.QuoteId = int()
Quote.BillToCustomer.StateAbbreviation = ''
Quote.BillToCustomer.TerritoryName = ''
Quote.BillToCustomer.Title = ''
Quote.BillToCustomer.UserId = int()
Quote.BillToCustomer.ZipCode = ''

Thank you.

- Sergey

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member

Hi Sergey

can you try:

BillToCustomer = Quote.BillToCustomer

Quote.SaveCustomer(BillToCustomer)

Sergey_L
Participant
0 Likes

Prashant,
I never noticed that SaveCustomer() was an option - that must be it! Thank you!

Unfortunately, we had to turn off the script before I could test it further - the system started glitching more often (notifications started failing intermittently, etc). I think we have too many CRM mappings, post actions, and notifications setup and they're overloading the system, especially if my scripts throw any errors. You see, we've been using CPQ as a CRM until we finally got a CRM. So we decided that we need to finish cleaning that up first before setting up any more scripts. But I have recorded your suggestion and will try it when the time comes. Thanks again!

- Sergey

Former Member
0 Likes

Hi Sergey

Add Quote.Save() at the end of the script to apply your changes to customer roles

Sergey_L
Participant
0 Likes

Thanks for the answer, Prashant!
Unfortunately neither Quote.Save() nor Quote.CalculateAndSaveCustomFields() did the trick.
In the same script, I also clear some regular custom fields and the above commands work to save those clearings. Customer selection, however, seems to work differently.