Hi,
I tried to create the Opportunity using the code attached(script was written under Opportunity XBO for Event-BeforeSave at Root) and i was able to create the opportunity.
var Data = Opportunity.Create(); Data.Name.content = "As a follow Up Activity"; Data.PriorityCode = "1"; Data.ProcessingTypeCode = "OPPT"; Data.GroupCode.content = "0026"; Data.HeaderRevenueSchedule = false; var ID = Data.ID.content; //if( !Data.Party.GetFirst().IsSet()) //{ var party = Data.Party.Create(); party.MainIndicator = true; party.PartyKey.PartyID.content = "1001979"; party.RoleCode = "31"; var party1 = Data.Party.Create(); party1.MainIndicator = true; party1.PartyKey.PartyID.content = "8000000001"; party1.RoleCode = "39"; //} //if(!Data.SalesCycle.IsSet()) //{ var new = Data.SalesCycle.Create(); new.SalesCycleCode.content = "Z02"; //} //if( !Data.SalesForecast.IsSet()) //{ var new1 = Data.SalesForecast.Create(); new1.ExpectedRevenueAmount.content = 200; new1.ExpectedRevenueAmount.currencyCode = "EUR"; new1.ProbabilityPercent = 10; new1.SalesRevenueForecastRelevanceIndicator = false; new1.ExpectedRevenueDatePeriod.StartDate = Date.ParseFromString("20160607"); new1.ExpectedRevenueDatePeriod.EndDate = Date.ParseFromString("20170607"); new1.ExpectedProcessingDatePeriod.StartDate = Date.ParseFromString("20160607"); new1.ExpectedProcessingDatePeriod.EndDate = Date.ParseFromString("20170607"); //} //if ( !Data.Item.GetFirst().IsSet()) //{ var new2 = Data.Item.Create(); new2.ExpectedRevenueDatePeriod.StartDate = Date.ParseFromString("20160607"); new2.ExpectedRevenueDatePeriod.EndDate = Date.ParseFromString("20170607"); new2.ExpectedNetAmount.currencyCode = "EUR"; new2.ExpectedNetAmount.content = 100; new2.Quantity.content = 2; new2.Quantity.unitCode = "EA"; new2.Description.content = "My Product"; if(new2.ItemProduct.IsSet()) { new2.ItemProduct.ProductCategoryHierarchyProductCategoryIDKey.ProductCategoryInternalID = "FS-01"; new2.ItemProduct.ProductKey.ProductID.content = "EI30EW35PS"; }
Please note that I just passed very few data which I felt was necessary according to my system. and with this i was able to create a new opportunity as follow:
Please try to use this code as reference and let know if you are getting any issues.
Thanks
Saurabh
Hi All,
I am able to create the Opportunity by following the above thread. I have scheduled a work flow rule to update the status based on condition.
It is working for the opportunities created via manually. But not working for Opportunities created via Code(at event before save)
Work Flow rule is of type scheduled--created on-- after 5 minutes
Once opportunity created via Code-if we go manually and do edit/some change and save then rule is updating this opportunity which got created via code also.
Any help on this highly appreciated..
Add comment