Skip to Content
0

Wrong value in Extension field created via SDK

Jun 16, 2017 at 09:34 AM

79

avatar image

Dear Experts,

We have the requirement to sum up the "expected value" of all the opportunities associated with a customer account with opportunities status "won", close date year is "current year" and store that total sum in a extension field in the account header:-

import ABSL;
import AP.FO.BusinessPartner.Global;
import AP.FO.BusinessPartnerRelationship.Global;
import AP.CRM.Global;
import AP.FO.Activity.Global;
import AP.Common.GDT;
var TotalAmount=0;
var OppQuery=Opportunity.QueryByElements;
var OppParams = OppQuery.CreateSelectionParams();

OppParams.Add(OppQuery.Status.LifeCycleStatusCode,"I","EQ","4");
OppParams.Add(OppQuery.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","GE",Context.GetCurrentSystemDate().StartOfYear());
OppParams.Add(OppQuery.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","LE",Context.GetCurrentSystemDate().EndOfYear());
OppParams.Add(OppQuery.PartyPartyKey.PartyID.content,"I","EQ",this.GetFirst().InternalID);

var OppRes= OppQuery.Execute(OppParams);

if(OppRes.Count()>0)
{ foreach(var OppIns in OppRes)
 { var ExpectedVal= OppIns.SalesForecast.ExpectedRevenueAmount.content;
   TotalAmount=TotalAmount+ExpectedVal;

   }
 this.CurrentCommon.GetFirst().Total=TotalAmount.ToString();

   }

But the value in the extension field is wrong as it should be equal to the 6000 INR i.e. equal to YTD revenue of the current account.

Can someone please help me to fix this issue ?

Regards,

Saurabh Sharma

wrong-value.png (21.1 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers