Need help with attachments - How to open attachments from AIF service method?

Hello,

I am working on a few service methods that attach files to DAX from a C# application and also to open the attachments. As per our business we have two ways that we need to be able to attach files.

  1. Attach files into DocuRef. I found the class and the method that does this via AIF custom service.

The class is : DocuActionArchie and the method is add(). This method expects two parameters(docuRef, _fileControlName) . I was able to successfully attach txt files that we need to be able to attach using the class and the method. The files are stored some where in our network and that solved my problem

  1. Now, I want to be able to open the attached files using the above steps. Are there any out of the box classes and methods that I can use like we have one above to attach the files?

  2. There is another way that we need to be able to attach files , in which case it is only for the users to open the files from a network folder and not from DAX like we did in step 1. For instance I am working on a new vendor creation AIF service request method that the third party (C#) application users use to create a new vendor creation request. That request is received by our DAX Accounting team and process it. In that process the C# application needs to attach some document that provides additional information that is used by our DAX team.

I have looked at the DPDocumentHandling class and its saveWebDocument() and saveWebDocumentClient() methods. It seems like it may be good for the Business connector API and not for the custom AIF services. So, I am wondering are there any out of the box class and methods that I can use to for this?

Any related links or code snippet would help me with what I am trying to do.

Thanks in advance!

Dave

As explained in step 1 above, the line of code docuActionArchive.add(docuRef,_fileControlName); works only from DAX when I tested the service method. But when I tried it from Visual studio I am getting the below error

“Stack trace: Invalid attempt to call DocuActionArchive.Add running in CIL on the client.”

error. Am I missing something?

I see what is happening. The docuActionArchive.add() method works only on the client side because in the add() method it uses WinAPI class to ineteract with the file(s) and this class only works when I tested it from the client.

For the code/method to run on the server I tested with WinAPIServer class instead and works fine when I tested from the Visual studio. In my case I am using AIF service method and it should also work fine when run in a batch as it runs on the server too.

Steps I have taken to fix the issue:

  1. Duplicate the docuActionArchive class and rename it to docuActionArchive

  2. Find the WinAPI class and replace it with WinAPIServer

  3. the attachFileName = WinAPIServer::getOpenFileName can be commented as I do not see this method in the WinAPIServer class. I am already getting the full path so I didn’t need this and just commented out.

  4. Replace the docuActionArchive class with the new class in the service method and compile and deploy the service group and try it from Visual studio.

It successfully save the file in the DocuRef table and also the file has been copied over to the destination.

I am still looking for a solution for the other two questions I have asked. Help is appreciated.