cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a UF from dynamic code UF (VB .net)

08-11-2021 4:43 PM
3309 views 5 comments
0 Likes
SAP Managed Tags
Subscribe

Hi

We are SAP Business One our version 9.3, with boyum

I am trying to make use of this guide, in C# to run a UF in some dynamic code, which has to be written in vb.net, due to company support requirements

The guide is

Guide - Launching a UF - macro in a new thread

The aim is after my main code has run I launch a UF which is a SQL report to display the new data

I am trying

Dim C As System.Threading.Thread = New Threading.Thread( 
Try 
   Dim universalFunctionToRun = "UF-131" 
   company.UniversalFunctions.Module.ActivateUniversalFunction(SBO.AddonLogic.Addon.AddonData, eventForm, universalFunctionToRun, "Dynamic code") 
Catch ex As Exception 
    SBO.UI.Notification.MessageBox("Error running UF: " & ex.ToString()) 
End Try ).Start

unfortunately this is struggling to compile.

and if I try

''Call MRP report
''message in status bar
       application.StatusBar.SetText("Opening MRP Purchase Orders Created...", SAPbouiCOM.BoMessageTime.bmt_long,1)
        Try
            Dim universalFunctionToRun = "UF-131" 
            company.UniversalFunctions.Module.ActivateUniversalFunction(SBO.AddonLogic.Addon.AddonData, eventForm, universalFunctionToRun, "Dynamic code")
        Catch ex As Exception 
            SBO.UI.Notification.MessageBox("Error running UF: " & ex.ToString())
        End Try

I get

Can any one suggest a solution or something to try

Thanks

0 Likes

Accepted Solutions (0)

Answers (2)

Answers (2)

seanarchernz
Explorer
0 Likes

Hi Ian,

Sorry, I haven't actually used the UniveralFunction object.

What error are you getting when you remove the company reference?

The only thing I can see in the code sample you reference is that the eventForm object is not defined and is not one I am familiar with. The B1UP code documents the company, application and form SDK objects but not eventForm. You could try replacing the eventForm value with the form object. However, eventForm could be something that is defined outside the scope of the Dynamic Code UF the same as the form, application, company variables.

Cheers,

Sean

Former Member
0 Likes

thank you for that

seanarchernz
Explorer
0 Likes

Hi,

You are referencing the company object which in the B1UP Dynamic Code is a reference to the standard SAPbobsCOM.Company object. The UniversalFunctions object will be an object in the B1UP libraries.

The sample you gave shows the UniversalFunctions being called directly rather than via the company object.

Former Member
0 Likes

Hi thank you. I believe I understand what you are saying.

Are you aware of any documents for the said library?

Or an example?

Any further help would be great