Skip to main content

Hi All, few questions from a colleague, re Document Macros

 

I guess you know, there is a standard functionality in “DMS” that allow to fill a Word document automatically with fields in IFS (Macro – VBA).
I’m looking for answers about those questions and it is not easy to find :

  • Are those fields able to come from different Views or is it necessary all fields should come from the same one ?
    o Exemple : I have a file in GED with macro, connected to the View "Purchase.Order". In the file I would like to get the "Manager" field coming from the LU Project. Do I need to add a customfield read only to bring the manager in the View "Purchase.Order" ?
  • Can we put a value in the Word document, depending on condition ?
    o Exemple : If a field in IFS is “YES” then the Macro populate a field in a certain value in the Word document. If “NO” then the Macro populate the same field with an other value ?
    The answer should be somewhere in the screen “Macro basic” but it’s too technical for me.
    Thank you,

@NMALKI 

Hi,
Regarding adding data from IFS into an Excel document there is a good base example in the Online Documentation (F1) reached from Basic Data/Macros Basic that you can build upon. In my example I will assume the Excel Application object (oXl) has been created according to that base example. I will also assume the rest of the supporting code is known and used.

In the Online Documentation, the example shows how to use row and column indexes together with the Cells() method. But to relate to your question about using something similar to Quick Parts/Fields in Microsoft Word I will use the Range() method instead in my example.

To set up the similar part to a Fields sMS Word] you should use the Name Manager (under Formulas) in Excel for your template. There you define Names for each cell you want to address. (I will not go into things like Scope, i.e. context validity of the Name between sheets and workbook here.)

Example:
Public Sub Test()

    Open_Excel

    Write_To_Range "MyRange", "DOC_NO"

End Sub

 

Public Sub Write_To_Range(range, attr)

    attrValue = ScriptValues.Item(UCase(attr)).Value

    oXl.range("MyRange") = attrValue

End Sub

 

Regarding inserting an SQL or function in the macro it would as Mathias mentioned be more of a development effort but very shorty it could be achieved by using the framework provided by IFS .Net Access Provider (IFSAP). Here you must of course take into consideration things like which version you work with and how to handle security and login aspects. Looking towards IFS Cloud you might also have to consider if REST API or more specifically oData should be a part of your future strategy. I have only worked with IFSAP yet in this context though.
At the same time, you may be able to achieve what you want with your SQL or function by implementation it via a Custom Field (which can be fetch from a connected object) or via a (unused) metadata field that is available as a standard document attribute to the macro (see F1 Help for available attributes). The value (i.e. the result of the SQL or function) could be inserted/updated via a Custom Event in the standard metadata field.

 

Hope this was to a little help anyway,

Erik


@xeam-eran you are amazing 🙂 thanks so much for your help. That's what I really need ...much appreciate


Reply