Trouble updating a Field in Salesforce via a Python Script

18 views Asked by At

First time posting on Stack overflow, so please bare with me lol

Objective: The project aims to streamline the process of updating driver's license numbers for contacts in Salesforce based on information obtained from a third-party website.

Workflow:

1). An agent initiates the process by clicking on a "Quote Auto" button or trigger in the Salesforce UI.

2). This action triggers a POST request to a Python bot with the customer's information (e.g., contact ID). 3). The Python bot retrieves the driver's license number by scraping data from a third-party website. 4). Once the driver's license number is obtained, the bot updates the corresponding contact record in Salesforce with the new driver's license number.

The problem I am facing, is when my script tries to update the "Drives license number" field, via my script, it doesn't update at all and I don't really understand why!

I obtained the contactID to update the correct contact object for the agent. Here is the code I am using to try to update the contact record.

def update_contact(dl_number, contactId): try: # Update the contact record with the new DL number data = { "TGS_Drivers_License_Number__c": dl_number }

    print("Updating contact with data:", data)
    result = sf.Contact.update(contactId, data)
    print("API Response:", result)
    
    if result == True:
        print("Contact record updated successfully")
    else:
        print("Failed to update contact record. Result:", result)
except Exception as e:
    print("An error occurred during contact update:", str(e))

The problem I am facing, is when my script tries to update the "Drives license number" field, via my script, it doesn't update at all and I don't really understand why!

Expectation - the field being updated with the new drivers license number

0

There are 0 answers