Showing results for 
Search instead for 
Did you mean: 

Problem with accessing to the fileds of LeanLead Business Object

0 Kudos

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?

Accepted Solutions (0)

Answers (2)

Answers (2)

Product and Topic Expert
Product and Topic Expert

Hello Sin,

It makes no sense to check in both BeforeSave and ValidateOnSave.
One is enough.

Second you need to make sure that your code is executed only if it makes sense: You need to determine if the current Lead is a MarketingLead and then execute your code.


0 Kudos


I have solved my problem, That was the problem of other part.