Community
Showing results for 
Search instead for 
Do you mean 
Reply

Creating a new Opportunity via API

New Member
Posts: 8
Country: United_Kingdom

Creating a new Opportunity via API

[ Edited ]

Hi

 

I am completely new to Act developing. I am submitting a JSON to the appropriate URL (see Figure 1 below). You can see that the "customFields" are filled in. The API then returns a confirmed copy of the inserted record (see Figure 2 below). This has a generated ID from the Act software. As you can see, all of the "customFields" data is missing. Also the "contactNames" data is also missing. The "name" and "status" fields appear to be the only fields which are being saved. My field names completely match the return JSON field names. No error message is being given as to why this information is not being saved. Also, despite this returning a confirmation-response with a server generated ID field (proving it has been processed), I cannot find this record anywhere in the Act portal in Opportunities. Any ideas what is going wrong? Act Verion: 18.2.64.0

 

Figure 1:
{
"name": "344238",
"status": 1,
"actualCloseDate": "2016-12-12T00:00:00+00:00",
"estimatedCloseDate": "2016-12-12T00:00:00+00:00",
"grossMargin": 0.00,
"isPrivate": false,
"isPublic": true,
"openDate": "2016-12-12T00:00:00+00:00",
"probability": 100,
"productTotal": 0.00,
"weightedTotal": 0.00,
"totalPerContact": 0.00,
"totalPerGroup": 0.0,
"totalPerCompany": 0.0,
"contactNames": "Test Name",
"competitor": null,
"source": null,
"reason": null,
"opportunityRelation": null,
"customFields": {
"quantity": "1",
"total discount": "0.00",
"invoice address 1": "1 Test Road",
"event code": "66177",
"price": "22.00",
"billing city": "",
"billing address 1": "1 Test Road",
"billing postcode": "A1 1AA",
"invoice city": "",
"invoice address 2": "",
"billing country": "United Kingdom",
"event type": "Partypack",
"event date": "02-02-2017 00:00:00",
"invoice postcode": "A1 1AA",
"billing address 3": "",
"invoice country": "United Kingdom",
"billing address 2": ""
},
"opportunityRelation": {
"productsAdded": [
{
"name": "partypack",
"price": 11.00,
"quantity": 2,
"total": 22.00
}
]
}
}


Figure 2:
{
"id": "e36ed0c7-7c52-4495-8f2e-9e6c0e756cc0",
"name": "344238",
"creator": "Test User",
"manager": "Test User",
"daysOpen": 0,
"status": 1,
"actualCloseDate": "2016-12-12T00:00:00+00:00",
"estimatedCloseDate": "2016-12-12T00:00:00+00:00",
"grossMargin": 0.00,
"isPrivate": false,
"isPublic": true,
"openDate": "2016-12-12T00:00:00+00:00",
"probability": 100,
"productTotal": 0.00,
"weightedTotal": 0.00,
"totalPerContact": 0.0,
"totalPerGroup": 0.0,
"totalPerCompany": 0.0,
"contactNames": "",
"created": "2016-12-12T22:04:17+00:00",
"edited": "2016-12-12T22:04:17+00:00",
"competitor": null,
"source": null,
"reason": null,
"opportunityRelation": null,
"customFields": {
"opportunity_field_1": null,
"quantity": null,
"total discount": null,
"invoice address 3": null,
"opportunity_field_8": null,
"invoice address 1": null,
"event code": null,
"price": null,
"billing city": null,
"billing county": null,
"billing address 1": null,
"billing postcode": null,
"invoice city": null,
"opportunity_field_7": null,
"invoice address 2": null,
"billing country": null,
"event type": null,
"event date": null,
"invoice postcode": null,
"opportunity_field_2": null,
"invocie county": null,
"billing address 3": null,
"invoice country": null,
"opportunity_field_3": null,
"billing address 2": null,
"booking date": null,
"opportunity_field_6": null,
"opportunity_field_5": null,
"opportunity_field_4": null
},
"editedBy": "Test User",
"recordOwner": "Test User"
}

Copper Super Contributor
Posts: 478
Country: Australia

Re: Creating a new Opportunity via API

Mate dont understand what your asking for in the message but judging by the title this may help

 

                // This example creates an Opportunity and then populates several of the Opportunities fields.
                // The Opportunity Variables
                OpportunityStatus oStatus = OpportunityStatus.Open;
                int iProbability = 50;
                DateTime dEstCloseDate = System.DateTime.Now.AddDays(15);
                Boolean bMakeItPrivate = false;
                string sName = "TEST Insurance (Life Cover)";

                ContactList cList = Act.UI.ActApplication.Instance.ActFramework.Contacts.GetContacts(null);
                Contact cContact = cList[0];

                Guid[] gArray = new Guid[1];
                gArray[0] = c.ID;

                //Process[] pProcess = StageManager.ActiveProcesses[];
                Stage[] sStages = Act.UI.ActApplication.Instance.ActFramework.StageManager.Processes[0].Stages;
                Stage oStage = sStages[5];

                // Opportunity Products
                ProductList pList = Act.UI.ActApplication.Instance.ActFramework.Products.GetProducts(null);
                Product pProduct = pList[10];

                // Opportunity Variables used after its ceated
                string sReason = "New application for Life cover with TEST, has been established for " + c.FullName + "";
                DateTime dOpenDate = System.DateTime.Now; decimal curval1 = 0;
                
                // Call to create opportunity
                Opportunity oOpp = Act.UI.ActApplication.Instance.ActFramework.Opportunities.CreateOpportunity(sName, oStatus, oStage, dEstCloseDate, bMakeItPrivate);
                oOpp.Probability = iProbability;
                oOpp.User7 = "Insurance";
                oOpp.Reason = sReason;
                oOpp.UpdateContacts(gArray, null); oOpp.Update();
                oOpp.Fields["TBL_OPPORTUNITY.CUST_AdviceFUM_050239770", true] = curval1;
                oOpp.Fields["TBL_OPPORTUNITY.CUST_AdvicePUM_050311460", true] = curval1;
                oOpp.Fields["TBL_OPPORTUNITY.CUST_AdviceSUM_050445029", true] = curval1;

                //Set a new Note
                Act.UI.ActApplication.Instance.ActFramework.Notes.CreateNote(noteTypes[0], "New Opportunity created titled " + sName + "\n" + sReason + "\n\nThis is under the " + oOpp.User7 + " opportunity type with " + pProduct.ToString() + " product style.", now, false, oOpp);

                oOpp.Update();

                // Call to add Product
                OpportunityProduct oProd = Act.UI.ActApplication.Instance.ActFramework.Products.OpportunityProductManager.CreateCustomEntity();
                oProd.Name = pProduct.ToString();
                oProd.Quantity = 1;
                oProd.Cost = 0;
                oProd.Price = 1;
                oProd.Discount = 0;
                oProd.SetOpportunities(Act.UI.ActApplication.Instance.ActFramework.Opportunities.GetOpportunityAsOpportunityList(oOpp));
                oProd.Update();

Jason Dawson Financial Planning
Brisbane | Australia - JDFP Home Page

Act Ver - Act! Premium Version 17.1.169.0, Hot Fix 3
OS - Windows 7 (stand alone machine)
MS Office - Enterprise 2007
Phone - Samsung Galaxy s6