Skip to Content
Nov 15, 2016 at 11:46 AM

Problem with accessing to the fileds of LeanLead Business Object

479 Views Last edit Nov 15, 2016 at 11:47 AM 2 rev

Dear Expert,

We have a requirement to set some filed of Marketing Lead as mandatory.(Seeing the error and is not possible to save that Lead)
For example fields like: City, Adress, Country,.

In SDK since we have just Lead.xbo, I have write our code in EventBeforeSave:
In order to access to LeanLead, I should write a query.

The problem is that, when we want to edit an existing Lead in C4C, it always check with the data that is in exist in LeanLead business Object.I mean It checks with data that was saved, not the data that now is editing!
So for example if user open a Lead that had Country, and then user by mistake remove the country, We will not see the error! Or if a field like City was empty, and user want to set a value for it, we see the error that City is Empty(although is not empty)
This is my Code in Event Before save

var query= LeanLead.QueryByElements; 
var param = query.CreateSelectionParams();
param.Add(query.LeadID.content, "I" , "EQ" , this.ID.content);
var result= query.ExecuteDataOnly(param);
var address= result.GetFirst().Address.PostalAddressElements;
this.SetProspectCheck = false;
	raise conditionalWarningCountry.Create("E");
	raise conditionalWarningCity.Create("E");
	raise conditionalWarningStreet.Create("E");

Also I have written related code in ValidationOnsave, in order to not allow to save.

I also tried with Retrieve instead of Query but the result is the same...

Can anyone help me about this?