on 01-02-2017 5:17 PM
Hello Team,
My requirement is to create copy/child opportunity on save of existing opportunity based on some conditions.
I have extended the Opportunity BO and generated script file for "Event Before save". I have retrieved the opportunities details in the business object node and am trying to make us of standard actions like "Copy" or "CreateChildwithReference". But in both the methods on passing the reference business object, its throwing an exception and unable to find it out.
Then I tried using "Create" function available in Opportunity, am passing all the parameters its executing but not returning me any new Opportunity i.e its not creating & saving any new opportunity.
Kindly help me out on the solution to create new reference opportunity thru ABSL on save of Opportunity.
Thanks,
Swadini S
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,Thanks for your reply. I have checked the same and it is having four fields in system administration data ,creation date and time,changed date and time,creation Uuid,changeduuid.
All fields are populated for the opportunity(created via code)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you please check if you create an opportunity via code then SystemAdministrativeData is correctly filled?
Because to me it seems like when you create opportunity via code then there is some issue with SystemAdministrativeData but when you edit it manually from UI then via standard process this missing field is also updated. Then it starts working.
Thanks
Saurabh
Thank you Saurabh, I am able to create and was about to update.
Regards,
Swadini S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.