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,

Hi,

By default, when a macro in IFS DMS (“Docman”) runs, it has access to a long list of attributes that can be used to fill in Word or any other file type that supports automation. There are no attributes from business objects connected to the document, by default. But this can be configured. So, if a document is attached to a purchase order, attributes from that purchase order can be used by the macro. And so on for other attached objects. We have some documentation about document macros (search for macros) that shows some examples on how to write a (very) simple macros and also on how to access attributes from connected objects. But, please note, writing macros is a kind of programming and you will need to learn some VBScript as well as learning the application you want to automate. If you have no competence on this yourself, reach out to IFS support or your contact at IFS, and see how they can help out. We also have partners (Addovation, for example) that have a good competence on Docman.

In the macro itself, since it is code, you can have as many conditions as you like. I hope that answers your second question.

Good luck!

/Mathias

 


thanks Mathias. I’ll pass this on.


There are also still some macro examples in the old wiki on openIFS with some information that might still be useful even if it is old.

 


Thank you very much Mathias !


@Mathias Dahl do you have any of these examples that you can share, or are they the same as loaded on OpenIFS?


@Mathias Dahl do you have any of these examples that you can share, or are they the same as loaded on OpenIFS?

The macros on openIFS are probably similar or the same as what we once had in IFS RACE/demo database: simple getting-started macros meant to be extended easily. Are you looking for something specific? Also, is it the “how do I control application X to do Y” part you are interested or is it “I don’t know VBScript or VBA” or “how can I access document attributes”?

 


Thanks for the response. I will take a look in OpenIFS. More specifically I am interested in how can i make the Macro populate the document with IFS Attributes or perform other functions. Also, the OpenIFS appears to have a certificate problem preventing access. 


Yeah, there seems to be a certificate problem, definitely.

In Chrome, click Advanced in the warning page that opens, then click “Proceed to… (unsafe)”. It should be safe to open that as long as you know that, in theory, any data you post there might not be encrypted properly.

I tried to start a macro repository there, but it never took off after my own examples were added (people want to have information, but seldom want to share, it is simply the way things are):

https://open.ifsworld.com/wiki/Wiki%20Pages/Document%20Management%20-%20Internal%20Macro%20Repository.aspx

 


Thanks, but I cant access it still, just get error 500 from chrome or IE. Any chance you can zip up some examples, just to get me started. I’m quite happy to share, but need to get the knowledge how to access the Word Object. in VBScript. 


Thanks, but I cant access it still, just get error 500 from chrome or IE. Any chance you can zip up some examples, just to get me started. I’m quite happy to share, but need to get the knowledge how to access the Word Object. in VBScript. 

I see. Does this link below help?

https://stackoverflow.com/questions/3863291/how-do-we-open-a-word-file-using-vb-script

 


Hi @Mathias Dahl ,

Can you share some insight on, how will you achieve the macro functionality in Aurena?


Hi @Mathias Dahl ,

Can you share some insight on, how will you achieve the macro functionality in Aurena?

Aurena supports macros in Docman since UPD7 or even UPD6, by using the Aurena Agent. In the rollout/news PPT we mention this, and we also mention there in what places macros are available (we did not have time to add it to all places in the first release).

 

 


Thanks Mathias. The link is good for vbscript context and syntax but it doesn’t give an insight into what is needed to access the document and the IFS objects. For example, say on creation of a new document it should populate the doc with the doc class, no, format and title, without a little insight the help docs just don’t have the detail. 


Thanks Mathias. The link is good for vbscript context and syntax but it doesn’t give an insight into what is needed to access the document and the IFS objects. For example, say on creation of a new document it should populate the doc with the doc class, no, format and title, without a little insight the help docs just don’t have the detail. 

Since I forgot to mention it earlier, I want to say this: the official end-user documentation does not have much details on “how to automate application X” (Word, Excel, AutoCAD or whatever), and it is on purpose since we don’t want to, and don’t have time to, support macro “code” for applications out there, since that code can get out of date easily.

So, what the documentation mentions is the general concepts in how a macro is defined, how to access document values, etc. It explains the “pieces of the puzzle” that is under control of IFS, you could say. In my view, our documentation on macros, plus “Googling for VBScript on how to do X” should get you a long way.

Do you think there are things that are missing in the official documentation, or that could be made clearer? Again, we want to avoid having Word-specific (or whatever) code in there, so keep that in mind. There is a heading called “The Macro Process” in the About Document Macros page that should explain the workflow for setting up a macro. Did you try to follow that? If yes, did you also get the basic macro example working? Once you get that working you will have a good basic understanding of the process. The rest is just code… :)

 


 

Hi, I can understand why IFS wouldnt want to support code, however there is a big gap between what is available in the help and online and what is possible. Even if just the fundamentals were made available for people to then go and then search online etc, but without the fundamental logic people like me have nowhere to start from. I’ve followed the example in the eLearning and it works fine, but displaying a messagebox and inserting a value from IFS into a document are totally different challenges. 

Take my example, which i think would be pretty standard, is that a macro, on check-in of a document into DocMan should populate 3 bookmarks with DocNo, DocClass, DocRevision.

 

Where/how do we execute this code, do we have to create a WordDocument VBScript object to access the doc, if so we must need to know the path, how do we get this ? you say, search code online but its the context on how to access the underlying doc, and the connected IFS object elements, say, shop order no, release, state, etc. that i will never find online. 

 

I feel like there is just a little bit of code on how to access the doc that DocMan is accessing that I am missing. I cant see OpenIFS (raised ICS case today on this).

 

I appreciate your responses as its great to be able to actually get some direct response from IFS. 

 

Dave. 

 


Hi, sorry for the late reply.

I understand you.

I think the answers to most or all your IFS-related questions can be found in the documentation. Again, we do not want to describe in detail in the documentation how to “do things” a certain application, we want that information to be as generic as possible (with that said, we have one example that is a little bit too detailed there, I think). Applications come and go, and we want to have a documentation and a macro concept that we can support for a long time. With some luck, you can run a macro from almost 20 years ago and it will still work...

Did you check the The Macro Process section? That should explain the process on how to setup a macro. Then there is further down lists of all the available attributes/values that a macro can use, including the file names of local files that are checked in or out. And there is also some examples on how to access these attributes, which is of course critical information.

I think you have been able to get a simple message box working. I suggest that you extend that by adding some attribute that you think looks interesting, to the message (hint: use the LOCAL_FILE_NAME_1 to get the original file name: ClientScriptValues.Item("LOCAL_FILE_1").Value should work). Do this for the attributes that you think you need (you can append values using & between strings if you don’t want to open multiple message boxes). Then add code (found on the internet) on how to start application X, how to add a bookmark for application X, etc.)

Good luck!

/Mathias

 


Although an older thread, I just want to add my thoughts.

What I missed in the documentation (or I couldn’t find it) is when I want to use attributes from more than one LU (Object Type). So starting of with the example of the original author of this post. I’m able to get order number and vendor number from the Object Type PurchaseOrder. However how does one retrieve the attributes from a connected Object Type such as PurchaseOrderLinePart.

Proofed that I had to use the field ‘Alternative View Name’ on Object Attributes for Macros. When filled with purchase_order_line_all it has the majority of the wanted fields.

Yes, I still miss the name of the vendor. That should be solvable by adding a customer field on LU PurchaseOrderLine. This custom field would retrieve the name of the vendor. A bit odd to have such a thing on a line level.

I’ve not played around with building a specific IAL (which is then the alternative view to be used). 

Someone any results with that (thinking of security issues)?

Steve


If the document is connected to a PurchaseOrderLinePart, then you just need to setup basic data under macro basic to get attributes from the LU available in macros. But if you only attach the document to the PurchaseOrder, then you cannot use the basic data for that. Then you might be able to solve it with a custom field, or use the last option and implement a PL/SQL method that can fetch whatever values you want to.

 


Hi Mathias and macro enthusiasts,

 

Sometimes it is useful to have the complete list of attributes and their values. I have tried to find a way to loop through them but to no avail so far.

In the User documentation there is a good example that can be used to loop through and list all available attributes for connected objects. Is there a way to do something similar for the “standard” document attributes?

Thanks,

Erik


Sometimes it is useful to have the complete list of attributes and their values. I have tried to find a way to loop through them but to no avail so far.

Hi Erik, long time no see :)

I found some old vbs that seem to do what you want (it writes all attribute names and values to a file, but it could equally well). I don’t know if it still works (but also cannot see why it should not).

Even if it does not work fully, perhaps it will give you some clue

 

Public Sub ListScriptValues()

    Dim objFileSystem

    Dim objTextStream

    Dim strMega

    Dim strFileName

    Dim i

    Const ForWriting = 2

    

    strFileName = "c:\temp\ScriptValues2.txt"

    

    If ScriptValues.Count > 0 Then

        For i = 1 To ScriptValues.Count

            strMega = strMega & ScriptValues.Item(i).Key & " = " & ScriptValues.Item(i).Value & Chr(13) & Chr(10)

        Next

    End If

    Set objFileSystem = CreateObject("Scripting.FileSystemObject")

    Set objTextStream = objFileSystem.OpenTextFile(strFileName, ForWriting, True)

    objTextStream.WriteLine "Available scriptvalues"

    objTextStream.WriteLine "======================"

    objTextStream.WriteLine ""

    

    objTextStream.Write strMega

    strMega = ""

    If ClientScriptValues.Count > 0 Then

        For i = 1 To ScriptValues.Count

            strMega = strMega & ClientScriptValues.Item(i).Key & " = " & ClientScriptValues.Item(i).Value & Chr(13) & Chr(10)

        Next

    End If

    objTextStream.WriteLine "Available client scriptvalues"

    objTextStream.WriteLine "============================="

    objTextStream.WriteLine ""

    

    objTextStream.Write strMega

    

    objTextStream.Close

    MsgBox ScriptValues.Count & " values written to file " & strFileName

End Sub
 

Why do you ask though? You know very well where to look for the PL/SQL code that creates this list in the first place :)

 


PS. I apologize for the formatting above. Although there is a way to add “code” to these posts, it does not always work like we want it to…

 


 

Why do you ask though? You know very well where to look for the PL/SQL code that creates this list in the first place :)

 

Thanks Mathias!

Nice to see you’re still at the Docman helm delivering quick and nice answers :)
Even though approaching the task assuming it was all “hidden” in a VB Dictonary I overlooked that “.Key” was the key here :)

Yes I know the database method 🙂 But your code will be helpful when developing solutions based on actual values and when debugging (showing all attributes and their values in one go).

/Erik


 


@Mathias Dahl

Just wondering how can I add (auto populate) data from IFS into an excel document please. 

Looking for the same functionality as Quick Parts - Field in Microsoft Word.

Another question: do you got any example on how to insert an SQL or function like Customer_Info_API.Get_Name(CUSTOMER_ID) into MACRO ? I am trying to retrieve the customer name and auto fill it into the document ..

Much appreciate your help.


Sorry, I don’t have the time to outline nor write such a solution right now. Let’s hope someone else will join in. What you want might be considered a small development effort actually, it’s not simply configuration. 


Reply