Method Community

 

Created a customer with API. Trying to create Opportunity

Last post 08-16-2017 11:02 AM by Method_Peter. 12 replies.
Page 1 of 1 (13 items)
Sort Posts: Previous Next
  • 08-21-2016 10:35 PM

    Created a customer with API. Trying to create Opportunity

    Hello,

    We've created a form on Joomla that creates a Customer, then creates an Opportunity for that Customer.

    We are able to create the Customer successfully, however the Opportunity is not showing up. We are trying to use the Name field to link the two.

    Are we doing the Opportunity the wrong way? If so, what would be the best way to link a new Opportunity to a Customer you just created?

    Thank you!

  • 08-22-2016 1:30 PM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    Hi GroGreen,

    Your workflow is correct. One thing to keep in mind is that your opportunity will be linked to the contact that is created automatically when you create a new customer. Using the same name that you used for creating the customer should still allow you to create and link the opportunity to the correct contact.

    If you're unable to locate the opportunity after attempting to insert it, perhaps there's an error in your payload. Are you able to view or log the message returned from Method after each API call is made using Joomla? This information could be the key to finding the problem.

    Alternatively, you could look into sending a test payload manually using a tool such as Postman. Postman will display the status code as well as the returned message. I hope this helps.

    --Audisho

    Audisho Sada
    Product Manager
    Method:CRM
    a.sada@method.me
    Toll Free: 1.888.925.6238
    Local & Overseas: 416.847.0400
    Fax: 416.640.6027
  • 07-31-2017 9:16 AM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    Hello,

    Is it possible for you to paste the postman code for Opportunity creation (so that it can be imported via its import tool "paste raw text")?

  • 07-31-2017 3:39 PM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    You can paste the code below - you will need to fill in your own Method CompanyAccount, Login and Password.  Also, the Customer, AssignedTo and OpportunityStage in the request are specific to your environment, choose values that make sense.

    After you paste the request, select XML (text/xml) for the content type and update the auto generated Content-Type header value to "text/xml; charset=utf-8" .  

    Postman is a fantastic tool but not always great for working with Soap APIs.  You will notice some strange formating in the response to this message.  Part of the response is wrapped in a CDATA tag (appears to be dropped in Postman) which is supposed to prevent that part of the response from being interpretted as XML.  You might find using a tool like SoapUI (open source version available) to review the MethodAPI easier. 

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
    <soap:Header/>
    <soap:Body>
    <tem:MethodAPIInsertV2>
    <tem:strCompanyAccount>{{CompanyAccount}}</tem:strCompanyAccount>
    <tem:strLogin>{{Login}}</tem:strLogin>
    <tem:strPassword>{{Password}}</tem:strPassword>
    <tem:strSessionID></tem:strSessionID>
    <tem:strTable>Opportunity</tem:strTable>
    <tem:arrInsertFieldsArray>
    <!--Zero or more repetitions:-->
    <tem:string>Name</tem:string>
    <tem:string>CloseDate</tem:string>
    <tem:string>Customer</tem:string>
    <tem:string>OpportunityStage</tem:string>
    <tem:string>AssignedTo</tem:string>
    </tem:arrInsertFieldsArray>
    <tem:arrInsertValueArray>
    <!--Zero or more repetitions:-->
    <tem:string>Oppty 3</tem:string>
    <tem:string>2017-08-31</tem:string>
    <tem:string>King Crafts</tem:string>
    <tem:string>Prospecting</tem:string>
    <tem:string>Peter Dyer</tem:string>
    </tem:arrInsertValueArray>
    </tem:MethodAPIInsertV2>
    </soap:Body>
    </soap:Envelope>

    Peter Dyer
    Product Manager - Method
  • 08-01-2017 1:55 AM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    Thanks for response. It makes things clearer now.

    The only question I have left is about the Customer value. AssignedTo is related to Customer table via Name fkey. But what exactly is Customer in Opportunity table is it company name from Customers table?

  • 08-01-2017 2:45 AM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    OK, managed to figure it out.

    'Name' = Just a string for example 'Oppty1'

    'OpportunityStage' = Browse some older already created opportunities to find default values. By default when you create a contact via Web2Lead it is 'Prospecting'

    'Customer' = This relates to Customer table Name field (you used it in creation of customer)

    'CloseDate' = just a date 2017-12-25

    'AssignedTo' = This is CRM Method username that will handle these requests. You can find that in settings and users when you login to crm method.

    I got one more question, now the opportunity is created properly but it as you can see in screenshot required field Contacts* is empty.

    http://imgur.com/N5oSAJe


    Is it possible to connect opportunity to contact (that get automatically created with new customer)  somehow?

  • 08-01-2017 9:38 AM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    Excellent, you have most of this figured out.  

    The Contact is set by setting the 'Contacts' value to the RecordID of the appropriate Contact in the same way you are setting the other fields (Name, OpportunityStage, etc).

    If you need to know the Contacts ID you can look it up in the Contacts table, like this:

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
    <soap:Header/>
    <soap:Body>
    <tem:MethodAPISelect_XMLV2>
    <tem:strCompanyAccount>{{CompanyAccount}}</tem:strCompanyAccount>
    <tem:strLogin>{{Login}}</tem:strLogin>
    <tem:strPassword>{{Password}}</tem:strPassword>
    <tem:strSessionID></tem:strSessionID>
    <tem:strTable>Contacts</tem:strTable>
    <tem:strFields>RecordID,Name</tem:strFields>
    <tem:strWhereClause></tem:strWhereClause>
    <tem:strGroupByClause></tem:strGroupByClause>
    <tem:strHaving></tem:strHaving>
    <tem:strOrderBy></tem:strOrderBy>
    </tem:MethodAPISelect_XMLV2>
    </soap:Body>
    </soap:Envelope>


     Adding the Contact RecordID changes the Opportunity insert to this:

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
    <soap:Header/>
    <soap:Body>
    <tem:MethodAPIInsertV2>
    <tem:strCompanyAccount>{{CompanyAccount}}</tem:strCompanyAccount>
    <tem:strLogin>{{Login}}</tem:strLogin>
    <tem:strPassword>{{Password}}</tem:strPassword>
    <tem:strSessionID></tem:strSessionID>
    <tem:strTable>Opportunity</tem:strTable>
    <tem:arrInsertFieldsArray>
    <!--Zero or more repetitions:-->
    <tem:string>Name</tem:string>
    <tem:string>CloseDate</tem:string>
    <tem:string>Customer</tem:string>
    <tem:string>OpportunityStage</tem:string>
    <tem:string>AssignedTo</tem:string>
    <tem:string>Contacts</tem:string>
    </tem:arrInsertFieldsArray>
    <tem:arrInsertValueArray>
    <!--Zero or more repetitions:-->
    <tem:string>Oppty 33</tem:string>
    <tem:string>2017-08-31</tem:string>
    <tem:string>King Crafts</tem:string>
    <tem:string>Prospecting</tem:string>
    <tem:string>Peter Dyer</tem:string>
    <tem:string>4</tem:string>
    </tem:arrInsertValueArray>
    </tem:MethodAPIInsertV2>
    </soap:Body>
    </soap:Envelope>


    Peter Dyer
    Product Manager - Method
  • 08-03-2017 4:27 AM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    Hi,

    need one more thing.

    I cant seem to make where clause work. I looked at ASP example and there it says you can create where like this Where (eg. Balance > 0). Tried things bellow didn't work:

     'strCompanyAccount' => '',
     'strLogin' => 'xxx',
    'strPassword' => 'xxx',
    'strSessionID' => 'xxx',
    'strTable' => 'Contacts',
    'strFields' => 'RecordID,Name,Email',
    # 'strWhereClause' => 'Name = "FirstName LastName"', // Tried it with name
    'strWhereClause' => 'Email = "target@mail.com"', // Also with email
    'strGroupByClause' => '',
    'strHaving' => '',
    'strOrderBy' => '',
    Response:
    <?xml version="1.0" encoding="windows-1252" ?><MethodAPI response = "Failure. There were problems with running the query, please verify your parameters" ></MethodAPI>

    When I run it without where clause it works but it returns all the data.

    Can you provide assitance with this?
  • 08-03-2017 4:44 PM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    Email='target@mail.com' - single quotes - should work.

    Peter Dyer
    Product Manager - Method
  • 08-04-2017 3:22 AM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    Thanks that solved it.

    Hopefully I wont need any more help (will see if I start to implement activities).

    Small suggestion, your API docs are good but as far as I can see most of the problems dont come from

    it but from generally lack of understanding about table structure/relations and required fields.

    My suggestion is to maybe add some examples of SOAP requests like you've posted on this thread to some common actions like creating a customer etc...

    I have one more question for you - while experimenting with API i had some improperly created Contacts entities. They show in Contacts list but when you try to edit them you get some errors. Is there a way to delete those corrupt entries? (Look at screenshot: http://imgur.com/NS8D2fl, when you click it it just shows empty screen with this message: http://imgur.com/yOPZ4Dk )

  • 08-04-2017 4:39 PM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    Thanks, that's an excellent suggestion.  I've noted it and we will towards better samples.  I need to do a bit more investigation on your Contacts question.

    In the meantime, this may be germaine to other API users but there are a couple things I find helpful when working with the API.

    1. All of the available calls - https://www.methodintegration.com/MethodAPI/Service.asmx
    2. All available tables - https://www.methodintegration.com/MethodAPI/Service.asmx?op=MethodAPITableListV2 (click through from #1).  You can execute this call directly on the website and the format of the call is listed.
    3. All fields for a specific table - https://www.methodintegration.com/MethodAPI/Service.asmx?op=MethodAPIFieldListV2 (click through from #1).  Similar to #2 you can execute this call directly on the website and the format of the call is listed.  The response will list all fields and includes which fields are required.
    Peter Dyer
    Product Manager - Method
  • 08-16-2017 10:54 AM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    I wanted to add a note to this thread about working with Customers and Contacts.  Customer to Contacts is a one-to-many relationship.  That is, one Customer can have many Contacts, but a Customer must have a least one Contact.  That is enforced by the Method UI and API, both create a Contact when a Customer is created.  However, in the UI there is no way to create a Contact without a Customer.  The API is more flexible and allows this.  That is what is happening in this case and the UI is not designed to handle it.

    A couple things to keep in mind:

    - When created a new Customer a new Contact is created automatically - include the appropriate Contact information and you won't have to make a subsequent call to update the Contact.

    - When creating a new Contact (outside of creating a new Customer) be sure to associate the Contact with an Entity (Customer in this case but other Entities are supported, such as, Vendors).  This is done by including the Entity Name in the call to create the Contact. Example:

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
    <soap:Header/>
    <soap:Body>
    <tem:MethodAPIInsertV2>
    <tem:strCompanyAccount>{{account}}</tem:strCompanyAccount>
    <tem:strLogin>{{login}}</tem:strLogin>
    <tem:strPassword>{{password}}</tem:strPassword>
    <tem:strSessionID></tem:strSessionID>
    <tem:strTable>Contacts</tem:strTable>
    <tem:arrInsertFieldsArray>
    <tem:string>Name</tem:string>
    <tem:string>Entity</tem:string>
    </tem:arrInsertFieldsArray>
    <tem:arrInsertValueArray>
    <tem:string>Test Contact</tem:string>
    <tem:string>Customer Name</tem:string>
    </tem:arrInsertValueArray>
    </tem:MethodAPIInsertV2>
    </soap:Body>
    </soap:Envelope>

    Peter Dyer
    Product Manager - Method
  • 08-16-2017 11:02 AM In reply to

    Re: Created a customer with API. Trying to create Opportunity

    Deleting a Contact is straightforward.  You simply need the RecordID.

    You can query all Contacts as follows(if you have a lot consider a Where clause to narrow the search, also include the Fields that are meaningful to you):

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
    <soap:Header/>
    <soap:Body>
    <tem:MethodAPISelect_XMLV2>
    <tem:strCompanyAccount>{{account}}</tem:strCompanyAccount>
    <tem:strLogin>{{login}}</tem:strLogin>
    <tem:strPassword>{{password}}</tem:strPassword>
    <tem:strSessionID></tem:strSessionID>
    <tem:strTable>Contacts</tem:strTable>
    <tem:strFields>RecordID,Name,FullName</tem:strFields>
    <tem:strWhereClause></tem:strWhereClause>
    <tem:strGroupByClause></tem:strGroupByClause>
    <tem:strHaving></tem:strHaving>
    <tem:strOrderBy></tem:strOrderBy>
    </tem:MethodAPISelect_XMLV2>
    </soap:Body>
    </soap:Envelope>

    Find the RecordID in the results and call Delete (identifying the Table to delete from in the call), example:

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
    <soap:Header/>
    <soap:Body>
    <tem:MethodAPIDeleteV2>
    <tem:strCompanyAccount>{{account}}</tem:strCompanyAccount>
    <tem:strLogin>{{login}}</tem:strLogin>
    <tem:strPassword>{{password}}</tem:strPassword>
    <tem:strSessionID></tem:strSessionID>
    <tem:strTable>Contacts</tem:strTable>
    <tem:intRecordID>4</tem:intRecordID>
    </tem:MethodAPIDeleteV2>
    </soap:Body>
    </soap:Envelope>

    Peter Dyer
    Product Manager - Method
Page 1 of 1 (13 items)