cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Opportunity from ABSL

Former Member
0 Kudos

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

View Entire Topic
former_member226
Employee
Employee

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