on 02-22-2013 8:47 PM
Greetings.
I am developing an AddOn, and in one of the screens I need develop a method of navigation that use some filters. In this case, I can only navigate the records of the current month. I am currently making use of a RecordSet and capturing the MenuEvent 'Previous', 'Next' and others. This way I can make the navigation, however, has some problems and have to constantly block the default load method of the SBO.
So, is there another way to accomplish this filter?
Thanks.
Hi Paulo,
I assumed you are using dbdatasource as your underlying data source for the form.
You can create a condition object and
oDBDataSource.Query(oConditions)
Regards
Edy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Paulo,
Sorry for the late reply.
There seems to be no direct way to filter the navigation button.
But we can make use of this method to show our expected record:
-Catch the before menu event of the Navigation Button.
-Use a RecordSet object to get the next/Previous docEntry you want to show.
-Set the DocEntry/PK of the record into the Condition.
-Execute the DBDataSource.Query(Condition) method
-Set the bubbleevents = false.
Regards
Edy
Hi Jairo,
I will try to explain this in a simplified form.
OnMenuEvent:
bool lBubbleEvent = true;
if (pVal.MenuUID == MENUID_NEXT || pVal.MenuUID == MENUID_PREVIOUS ||
pVal.MenuUID == MENUID_FIRST || pVal.MenuUID == MENUID_LAST)
{
//oNavInicio = Determines if this is the first time that this browsing
//Whenever filter the RecordSet, set to true
if (pVal.BeforeAction)
{
switch (pVal.MenuUID)
{
case MENUID_NEXT:
if (oNavInicio)
{
oRecordSet.MoveFirst();
oNavInicio = false;
}
else
{
if (!oRecordSet.EoF)
{
oRecordSet.MoveNext();
if (oRecordSet.EoF)
oRecordSet.MoveFirst();
}
}
break;
case MENUID_PREVIOUS:
if (oNavInicio)
{
oRecordSet.MoveLast();
oNavInicio = false;
}
else
{
if (!oRecordSet.BoF)
oRecordSet.MovePrevious();
else
oRecordSet.MoveLast();
}
break;
case MENUID_FIRST:
oRecordSet.MoveFirst();
break;
case MENUID_LAST:
oRecordSet.MoveLast();
break;
}
Form.Freeze();
// Put form in OK Mode
mForm.Mode = BoFormMode.fm_OK_MODE;
// Filter the DBDataSource with RecordSet's current record.
LoadByDocEntry(oRecordSet.Fields.Item("DocEntry").Value);
mForm.UnFreeze();
// Don't let the following the normal flow of SBO event
lBubbleEvent = false;
}
}
bubbleEvent = lBubbleEvent;
LoadByDocEntry
private void LoadByDocEntry(int aDocEntry)
{
Conditions oConditions = Connection.Interface.CreateObject(BoCreatableObjectType.cot_Conditions);
Condition oCondition = oConditions.Add();
oCondition.Alias = "DocEntry";
oCondition.Operation = BoConditionOperation.co_EQUAL;
oCondition.CondVal = Convert.ToString(aDocEntry);
Form.DataSources.DBDataSources.Item("YOUR_TABLE").Query(oConditions);
Form.DataSources.DBDataSources.Item("YOUR_TABLE").Offset = 0;
}
FilterRecordSet
private void FiltrarRecordSet()
{
oRecordSet = (SAPbobsCOM.Recordset)Connection.Database.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
oRecordSet.DoQuery(string.Format("select DocEntry from [YOUR_TABLE] where FIELD_TO_FILTER = {0}", VALUE));
oNavInicio = true;
}
List of MenuID:
MENU ID | ID |
---|---|
First Data Record | 1290 |
Previous Record | 1289 |
Next Record | 1288 |
Last Data Record | 1291 |
I hope I haven't forgotten anything.
Any questions please write below.
Regards,
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.