Skip to Content
0
Apr 19, 2021 at 02:59 PM

SAP MDK - Error Executing OpenDocument Action

304 Views

Hi,

I’m using an image collection to display a list of images that come from an OData Entityset. The images are downloaded using a DownloadMedia action when the image collection loads and and stored on the file system. Finally the path is loaded in the collection and they are being displayed correctly.

When I press an image I have a rule that retrieves the path to the file system where the image is located and uses the OpenDocument action to display the image. However I always get an error saying Error: OpenDocument: Failed to open document.

I validated the path and the paths to load the image to the image collection and the one on the OpenDocument are the same.

Do I need to set up something in order to use the OpenDocument action?

Rule that calls the open document Action

import { fileExists } from './Utils/File/FileExists';
import { imageToPath } from './Utils/File/ImageToPath';
/**
* Describe this function...
* @param {IClientAPI} context
*/
export default function OpenDesignDocument(context) {
    let pageProxy = context.getPageProxy();
    let prod = context.getPageProxy().getActionBinding();
    let targetFolderName = 'ProjectDocuments';

    //Get the filename based on the ProductId's value
    let fileName = imageToPath(prod, 'DocumentID', targetFolderName);

    if (fileExists(fileName)) {
        // media is local and can be opened
        pageProxy.setActionBinding({
            'FileName': fileName,
        });
        context.executeAction("/mobileapp/Actions/Service/Design/OpenDesignDocument.action").then(result => {
            console.log(result)
        }).catch(error => {
            console.error(error)
        })
    } else{
        console.log("No file")
    }
}

Thank you in advance.