Skip to Content
0

Access Close date field of opportunity via PDI

May 12, 2017 at 08:52 AM

563

avatar image
Former Member

Dear Experts,

My team is currently working on a requirement in which we need to access the close date of an opportunity and accessing the year of the date.

OppParams.Add(OppQuery.,"I", "EQ","");

We are not able to find the path to access these fields so that we can add selection parameters.

Warm Regards,

Pragati

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

4 Answers

Best Answer
Deepak Singhal May 18, 2017 at 05:34 PM
0

Hi Pragati,

Did u try using this code..

OppParams.Add( OppQuery.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","GE",Context.GetCurrentSystemDate().StartOfYear() ); OppParams.Add( OppQuery.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","LE",Context.GetCurrentSystemDate().EndOfYear() );

Thanks,

Deepak

Show 7 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Deepak,

I have used this expression as suggested by @horst.schaude , now in next step when I try to assign the sum of expected values to a extension field declared in Business Object extension, then it shows me error Identifier "Total" does not exist where I have declared this element in XBO.

Below are the screenshot

Can you please help me here?

Regards,

Pragati

1.png (26.7 kB)
2.png (27.1 kB)
0

Hi Pragati,I

As I can see you created extension field within Common Node for Account.xbo, there you have to use GetFirst() after any node to get your extension field.

Regards,

Deepak

1
Former Member

Hi Deepak,

Yes I created it in Common node.

1) Is there any way out that I can create this field not in common node but any other node or anywhere so that I can access this field directly without using GetFirst()?

2) Also I have tried using GetFirst(), solution saved and activated successfully without error. Now when I open up the system and open an "account" then after modification into screen I click on save and it keeps loading in both silverlight n html client (below screenshot).

Please help with above two points.

Regards,

Pragati

1.png (51.9 kB)
0

Hi Pragati,

You can create the field at root level. Just define the element in the root node i.e. above AddressInformation node in your screenshot. By this way you will be able to access it without getFirst().

Thanks

Jayant

1
Former Member
Jayant Saini

Hi Jayant,

The root node is not extendable of customer BO. This is the error I get when I try to define the element in root node.

Also When I defined the element in common node I have to use retrieve it via getfirst() and solution is activated without error. That is fine but when I try to test the solution by updating the opportunity screen keeps uploading .

Can you please help me like why it is happening?

Regards,

Pragati

abc.png (30.5 kB)
xyz.png (51.9 kB)
0

Hi Pragati,

You can try creating the Total field via UI i.e. extension field from UI through adaptation at the header level. That way you can directly access the field in the sdk.

Thanks

Jayant

0
Former Member

ok Thanks a lot! But why the screen is getting blocked when I click on save tab? It should show the result in the field. But instead it keeps loading. Why this is happening and how can I resolve this?

Regards,

Pragati

0
Saurabh Kabra
May 12, 2017 at 01:57 PM
0

Hi,

Can you please following code to fetch based on EndDate?

param.Add( query.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","EQ",Context.GetCurrentSystemDate() );

Thanks

Saurabh

Show 8 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Saurabh,

Thanks for your reply. I actually want to access the year of the close date like this below scenario:-

for e.g. close date is 12.05.2017 then I want "2017" to be equal to the "current year" of the current date

"Close date's year of opportunity= "current date year"

How can I extract the current years from both the dates i.e. from "close date" and "current date"?

Regards,

Pragati

0

Hi Pragati,

To fetch the current year of date just use :

Context.GetCurrentSystemDate().GetYear()

And now if you want to fetch all the opportunities for which "Close Date Year = Current Date Year" then it is not supported by standard Query for Opportunity. In that case, You need to have a custom BO( which will have Opportunity as Association ). This Custom BO can have a query Parameter "Close Date Year".

Thanks

Saurabh

1

Hello Pragati,

Can't you use such an expression:

param.Add(query.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","GE","01.01.2017");
param.Add(query.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","LE","31.12.2017");

So you query for all Opportunities closed between January 1st and December 31st.

Beware that in the code above the date format may differ from yours. :-)

HTH,
. Horst

1
Former Member
Horst Schaude

Hi Horst,

Thanks for replying. I actually want date's year should be updated automatically that's why I wanted to compare opportunity close date year to current year. Otherwise this expression works for me but I will have to update the year in code manually once in a year :p

Isn't it possible by any way to fetch the opportunity close date year ?

Regards,

Pragati

0

Hello Pragati,

Why don't you use the inbuilt functions to determine the start and end of the year like here:

var startOfYear = Context.GetCurrentSystemDate().StartOfYear();
var endOfYear   = Context.GetCurrentSystemDate().EndOfYear();

HTH,
. Horst

0
Former Member
Horst Schaude

Hi Horst,

The above scenario of getting start date and last date of year is clear. But I want to fetch the year of opportunity "Close date" field in opportunity header but this field is a standard field.

For e.g. if the "close date" of an opportunity is 10.01.2017 the I want the year of this date.

My motto is to sum up all the expected values of opportunities(corresponding to an account) where close date year is equal to the current year. And for this I'm passing the parameter "close date" of opportunity.

Regards,

Pragati

0

Hello Pragati,

The functions "StartOfYear()" and "EndOfYear()" can be applied to every element of the type Date.
Also valid for standard fields.

HTH,
. Horst

1
Former Member

Hi Saurabh,

Our motto is to store the sum of all expected values in a extension field with close year is equal to current year but with opportunity status is won. We wrote this code in After-modify event:-

import ABSL;
import AP.FO.BusinessPartner.Global;
import AP.FO.BusinessPartnerRelationship.Global;
import AP.CRM.Global;
import AP.FO.Activity.Global;


var TotalAmount=0;
var NetCurrency ="";








var OppQuery=Opportunity.QueryByElements;
var OppParams = OppQuery.CreateSelectionParams();
OppParams.Add(OppQuery.Status.LifeCycleStatusCode,"I", "EQ","4");
OppParams.Add( OppQuery.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","EQ",Context.GetCurrentSystemDate() );
var OppRes= OppQuery.Execute(OppParams);


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


   TotalAmount=TotalAmount+ExpectedVal;
   }
   }<br>

But We want to extract the year of close date. So how should I do this by custom BO & association? Can you explain the steps? Former Member Hi Sunil Can you please help me here?

Warm Regards,

Pragati

0
Jayant Saini May 25, 2017 at 01:00 PM
0

Once I faced the similar issue in which my screen keeps loading endlessly and it was due to a dynamic dropdown whose property was set to static rather than dynamic. Have you customized this screen/ added some field or any type of changes ?

Thanks

Jayant

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member May 26, 2017 at 08:09 AM
0

Hi Jayant,

I have done code list mapping. Created a drop down field using KUT and tried to control ABC classification using code list restrictions. This is what I did only recently as far as dynamic dropdown is concerned. Can you advice how can I resolve this endless loading of screen?

Regards,

Pragati

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

Hi Pragati,

As far as I can tell you its due to your dropdown field using code- list restrictions. What you can do is open the screen in UI designer and check the properties of the dropdown field that you have created and under Behaviour > DynamicBackendActivated > set it to true. If you still face the issue we can discuss it.

Thanks

Jayant

1
Former Member

Hi Jayant,

I have created that field via KUT not via PDI. I have removed that field. But still Screen is getting locked. Request you to please help.

Regards,

Pragati

0

Hi Pragati,

From the screenshot I can see that you are using some Sales intelligence for accounts functionality, have you customized it? or how did you add it in the customer screen. As this is not a standard function, it may be causing the problem.

Regards,

Jayant

1
Former Member
Jayant Saini

Hi Jayant,

I am getting a value in my extension field now and system is not getting locked. (below screenshot). But the value is wrong as it should be 6000 (the expected value of opportunity(s) associated to this customer only which close date year is 2017 ).

Below Code:-

If I do like this then it shows wrong value in the field

var OppQuery=Opportunity.QueryByElements; var OppParams = OppQuery.CreateSelectionParams(); OppParams.Add(OppQuery.Status.LifeCycleStatusCode,"I", "EQ","2"); OppParams.Add(OppQuery.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","GE",Context.GetCurrentSystemDate().StartOfYear()); OppParams.Add(OppQuery.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","LE",Context.GetCurrent

And if I do like this:-

1) Created AccountID extension field:

element AccountID:BusinessPartnerInternalID;

2) Then in ABSL event

var OppQuery=Opportunity.QueryByElements; var OppParams = OppQuery.CreateSelectionParams(); OppParams.Add(OppQuery.Status.LifeCycleStatusCode,"I", "EQ","2"); OppParams.Add(OppQuery.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","GE",Context.GetCurrentSystemDate().StartOfYear()); OppParams.Add(OppQuery.SalesForecastExpectedProcessingDatePeriod.EndDate,"I","LE",Context.GetCurrent

OppParams.Add(OppQuery.PartyPartyKey.PartyID.content,"I","EQ",this.CurrentCommon.GetFirst().AccountID);


Please help why it is still not talking any value as I have now added one more parameter to refine the data so that it fetches opportunities with their associated accounts.

Regards,

Pragati

accountid.png (79.8 kB)
0