cancel
Showing results for 
Search instead for 
Did you mean: 

Select items

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

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?

Nussi
Active Contributor
0 Kudos

Duncan,

in c# set the value of a cell like this:


((SAPbouiCOM.EditText)((SAPbouiCOM.Matrix)(oForm.Items.Item("38").Specific)).Columns.Item("17").Cells.Item(pVal.Row).Specific).Value = "MyText";

lg David

Former Member
0 Kudos

Which is the item("17") on the A/R invoice form? I would like to change the price of the item before tax is calculated when i select the item from the items list.

Former Member
0 Kudos

Hi duncan,

The column 17 was the Price after Dsicount.

For the Unit price, it was the column 14

Gross Price, it was column 20

Michael

Nussi
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hey thanx for all your help, now one more small thing, i have used the methods above but there is an error when the program tries to write the value to the matrix, it says form item is not editable. Any help?

Former Member
0 Kudos

HI,

Check event it is really editable (form settings->table view-> Active flag!)

Regards

J.

Former Member
0 Kudos

Yes the active check box is checked but am still getting the same error.

Former Member
0 Kudos

which col r u editing? unit price or price after discount?

if you post the line which edits it might help to answer.

regards,

Binita

Former Member
0 Kudos

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?

Former Member
0 Kudos

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

Former Member
0 Kudos

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());

}

}

}

}

}

Former Member
0 Kudos

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

Former Member
0 Kudos

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?

Former Member
0 Kudos

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

Former Member
0 Kudos

Okay, the work around seems to be intensive and i did not want to use the DI API due to performance issues.

How would i iterate through the unit price column multiplying the values by for example 2 once the items are loaded onto the form?

Former Member
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

How would i put the field values on the matrix of the A/R invoice form? (in code)