on 07-23-2008 8:05 AM
I need to select multiple items for example on the items list form of the A/R invoice and for each item selected add 1 to the price and display it on the items grid.
How would this be done in code?
Hi
see the code below:
otmpform = SBO_Application.Forms.GetForm(pVal.FormTypeEx, pVal.FormTypeCount)
...
Case SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST
If pval.BeforeAction = False Then Exit Sub
If pval.ColUID = "1" Then
Dim oMatrix As SAPbouiCOM.Matrix = otmpform.Items.Item("38").Specific
oMatrix.Columns.Item("17").Cells.Item(pval.Row).Specific.string = "1"
End If
it runs as many times as selected item in the list
Regards,
J.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am using C#, i have tried:
SAPbouiCOM.Matrix oMatrix;
oMatrix = ((SAPbouiCOM.Matrix)(oForm.Items.Item("38").Specific));
oMatrix.Columns.Item("17").Cells.Item(pVal2.Row).Specific = "1";
but i am getting the error:
Property or indexer 'SAPbouiCOM.ICell.Specific' cannot be assigned to -- it is read only
Also, which is the item("17") on the A/R invoice form?
Duncan,
how you find out which is the column:
Be sure under "View" (Menu) you enabled "System Information".
than move the mouse under the columns and you see in the status bar the information you need
(Business One has to be maximized)
Sales Order - Mouse is over "Quantity" -> StatusBar you see
[Form = 139 Item = 38 Colum=11
take the "11" and use my code to set the quantity
got it ?
lg David
I am trying to edit the unit price column.
1. I am trying to charge a value of 5% before i sell the item, when the user selects the item i need to multiply the price of the selected item by 1.05 so that if the initial price was 100 it would be 105 when viewed on the matrix.
2. How would i do it for many items selected?
duncan,
I think the event u caught is wrong,
in addition to , you make it active from form settings,
try this code
If pVal.FormType = "133" And pVal.ItemUID = "38" And pVal.ColUID = "1" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_LOST_FOCUS And pVal.Before_Action = False Then
Try
Dim omat As SAPbouiCOM.Matrix
oform = SBO_Application.Forms.ActiveForm
omat = oform.Items.Item("38").Specific
omat.Columns.Item("14").Cells.Item(pVal.Row).Specific.value = 'put here modified price without currency
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
and yes, it works for multiple items' selection too.
HTH,
Binita
I have tried using your method in C# as below but its not working, i dont think the lost focus event handler should be there.
When i remove the lost focus event it gives me an error that the item is not editable. I have also checked the flag in form settings so it cant be that.
Anyone help, am running short of time!!
private void SBO_Application_ItemEvent2(string FormUID2, ref SAPbouiCOM.ItemEvent pVal2, out bool BubbleEvent2)
{
BubbleEvent2 = true;
if (pVal2.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST)
{
if (((pVal2.FormType == 133) & (pVal2.Before_Action == false) & (pVal2.EventType == SAPbouiCOM.BoEventTypes.et_LOST_FOCUS)))
{
if ((pVal2.ColUID == "1") & (pVal2.ItemUID == "38"))
{
try
{
SAPbouiCOM.Matrix oMatrix;
oForm = SBO_Application.Forms.Item(FormUID2);
oMatrix = ((SAPbouiCOM.Matrix)(oForm.Items.Item("38").Specific));
((SAPbouiCOM.EditText)oMatrix.Columns.Item("14").Cells.Item(pVal2.Row).Specific).Value = "1";
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
}
Duncan,
why have you enclosed your Lost_Focus event within ChooseFromList?
if (pVal2.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST)
{
if (((pVal2.FormType == 133) & (pVal2.Before_Action == false) & (pVal2.EventType == SAPbouiCOM.BoEventTypes.et_LOST_FOCUS)))
CFL event for such edit will give error. use just Lost_Focus. make it sure the flag for active in form settings is on. do it manually. and the code I sent works for sure.
regards,
Binita
Your help is greatly appreciated Binita, i managed to get it working to some level.
However with use of the lost focus event, if focus is changed to another part of the A/R invoice form and lost again(e.g. clicking on another field), the code re-calculates/ re-executes giving a wrong value to the matrix field.
Is there a cleaner way to catch the event?
Duncan,
I did expect this question after I posted the reply
a time consuming workaround. every time the lost focus happens and before you update price, with the a select query , check the original price from item master with the one of your active row's. if matching, then only modify.
another way is to compare the Gross Profit base price column, but I would not recommend it as you can have different price list settings at your end for gross profit.
regards,
Binita
Duncan,
the only place, where you can do such thing is , when you click add button.
If pVal.FormType = "139" And pVal.ItemUID = "1" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK And pVal.Before_Action = False Then
Try
oform = SBO_Application.Forms.ActiveForm
mat = oform.Items.Item("38").Specific
For i = 1 To mat.VisualRowCount
If mat.Columns.Item("17").Cells.Item(i).Specific.value <> "" Then
mat.Columns.Item("17").Cells.Item(i).Specific.value = 'modified price
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
try it
regards,
Binita
Edited by: Binita Joshi on Jul 25, 2008 2:12 PM
read the line as If mat.Columns.Item("17").Cells.Item(i).Specific.value not equal to sign "" Then
Hi duncan,
You can assign the price to 1 at the et_CHOOSE_FROM_LIST event.
When you choose the itemcode, you put 1 in the price field.
Hope it's help you
Regards
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
6 | |
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.