/scripts/ahub.form.attachments.js
0

Creating Opportunity from ABSL

Jan 02, 2017 at 05:17 PM

487

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Saurabh Kabra
Jan 03, 2017 at 09:52 AM
2

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


capture.jpg (59.0 kB)
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 06, 2017 at 08:06 AM
0

Thank you Saurabh, I am able to create and was about to update.

Regards,

Swadini S

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 09, 2017 at 03:53 AM
0

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..

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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

0
Former Member

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)

0
avatar image
Former Member Mar 09, 2017 at 06:40 AM
0

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)

Share
10 |10000 characters needed characters left characters exceeded
Skip to Content