You need to sign in to do that
Don't have an account?
bigga
Create New Account/Contact/Opportunity via Applescript and SalesforceScripting App
I was thrilled to find this:
tell application "SalesforceScripting" set mySession to login username "myemail@mydomain.com" password "passwordtokenhere" -- Create a new Account in Salesforce set acc to make SObject set type of acc to "Account" acc setField named "Name" to "3 New Test Account" acc setField named "PDS__QB_Billing_Address__c" to "3 New Test Account John Doe 123 Main Street Arlington, TX 75007" acc setField named "Phone" to "(888) 555-6666" set res to mySession create sobjects acc Id of first item of res end tell
And It works like a champ. I've spent the last couple of hours scouring the net and the script library trying to find out how to use something similar, or to add to it, so that I can create an Opportunity and Contact by adding some instructions to this.
I'm stuck. I guess I don't know enough about Apex and the SF system yet to read what needs to be in the script.
Any insight as to how to add Accounts/Contacts/Opportunities at the same time would be greatly appreciated.
All Answers
More on the Add Account script - this part:
works as it should when the phone number is in the format of "(888) 555-6666" - I get phone numbers if various formats, so I have another part of script that reformats the number to be just a string of numbers like "8885556666"
But after adding the account via the script, I get a weird calculated result in that field instead of the phone number
Progress! Using the applescript snippets on PocketSoap.com, I got this to reliably create a New Account and Related Contact via applescript:
The commented lines near the end are my feeble attempt at adding a Contact Role to this fresh new contact. I'm using the SFFieldDescribes and FieldDescribe snippets to determine the names/positions of these fields. Nothing I try works.
The script above returns:
But I can't figure out the correct syntax to add a Contact Role to the new Contact in the Account/Contact creation script
You would add a contact role in the same fashion that you created the related contact. If you're struggling to discover field names etc, you might want to look at SoqlX which will let you explore your salesforce schema.
Thanks for the reply Simon. Standing back and taking another look at the records/fields with the SoqlXplorer made it clearer. This bit of code appended to the above assigns the Contact Role to the just created contact and makes it the Primary contact:
Still working on
- getting SF to read 7778887777 as a phone number and not a calculation
- Adding an opportunity using an account lookup
For the lookup part, I know that MailDrop can do this - how can I look up an account by typing a partial name into a dialog box and then choosing an account to assign a new opportunity to?
I'm completely stuck on this: I've tried every trick I know, and none of them work. Here's where I am:
I've been staring at Soql Xplorer all day - I know the answer is staring me in the face, but I can't see it.
You want to do the lookup/filter in the query, something like
Progress! The "+" characters need to be "&" for that code to work.
As written, the code returns the first record it finds. I'm stuck in the middle of the repeat, I think.
For example, I have multiple accounts containing 'oak' - "Red Oak", "Mrs. Oakes", "Oakleaf", etc. I need to show a list to choose from.
Persistence pays... this part will look up an account by searching the first few letters of the account name:
I'd like to be able to search the entire account name, not just the first part of the name. This line here restricts the search to "startswith"
I've tried "name from account where name contains" and a few other iterations, however I can't get past this part
- I can parse the info from my Apple Contacts and create a new account and contact in SF with Applescript and SalesForceScripting.
- I can create a new opportunity for any account using SalesForceScripting.
That is, until today. The Account and Contact creating is working OK, but the script is simply failing to create an opportunity. I've been staring at this for hours until my eyes are crossed. The weird thing is that sometimes it works OK - and creates an opportunity. Just not every time. And I can't for the life of me figure out how it's failing.
Here's the code:
The NewOppID should be a long string (similar to 006E000000bPi7o) that I can append to a salesforce.com url to show the opportunity-- like this
my.salesforce.com/006E000000bPi7o
It just isn't working today, and I can't figure out why - no updates to the OS, or applescript software in months. Currently on Yosemite 10.10.5
Now I feel dumb making you do code on a Saturday. Have a pint on me when you get to the pub. Thanks so much for your help.