Forum Discussion

AshuJoe's avatar
AshuJoe
Ideator I
4 months ago

Load Item on Aras Sidebar Button

Hello, 
I am new to Aras, I was trying to load a Item instance of different itemtype into part.
I tried to follow sidebar_default_gv_click method and able to load the form. but the i am trying to load the item instance, which is not working.
Below is the Html Page which is loding the form in view only mode and if I try to change it into edit mode it dosent work.

<!doctype html>
<!-- Modified version of ShowFormAsADialog.html for inline rendering -->
<html>

<head>
    <style type="text/css">
        @import '../javascript/dojo/resources/dojo.css';
        @import '../javascript/dijit/themes/claro/claro.css';
        @import '../javascript/include.aspx?classes=common.css';
        @import '../styles/common.min.css';
        html,
        body {
            overflow: hidden;
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
        }
    </style>

    <script type="text/javascript" src="../javascript/include.aspx?classes=ArasModules,ScriptSet2"></script>
    <script type="text/javascript" src="../javascript/include.aspx?classes=/dojo.js" data-dojo-config="baseUrl:'../javascript/dojo'"></script>

    <script type="text/javascript">
        function getQueryParam(name) {
            const match = location.search.match(new RegExp(name + '[:=]([^&]+)'));
            return match ? decodeURIComponent(match[1]) : null;
        }

        window.onload = function() {
            const aras = parent.aras || window.aras; // Try to get aras context

            const formId = getQueryParam('formid');
            if (!formId || !aras) {
                document.body.innerHTML = "<center>Form not specified or ARAS context missing.</center>";
                return;
            }

            const formNd = aras.getFormForDisplay(formId);
            if (!formNd) {
                document.body.innerHTML = "<center>Unable to load form metadata.</center>";
                return;
            }

            const formFrame = document.getElementById('formFrame');
            const win = formFrame.contentWindow;
            const item = null
            const formType = 'view'

            setTimeout(() => {
                aras.uiShowItemInFrameEx(
                    win,
                    null, // item.node if you have it
                    formType,
                    0,
                    formNd.node,
                    null // itemTypeNd if required
                );
            }, 100);
        };
    </script>
</head>

<body class="claro">
    <iframe height="100%" width="100%" id="formFrame" frameborder="0" scrolling="auto" src="blank.html"></iframe>
</body>

</html>

Here I used item=null as aras.getItembyId(); is also not working.
can someone help me with using aras.uiShowItemInFrameEx(); method because it is loding the form and this is the method through which I think i will be able to load Item Instance.
Can anyone help me with how to load the form of diffrent itemtype through sidebar button?

 
 

1 Reply

  • You need to first retrieve the actual item using aras.getItemById("ItemType", "ItemID") and then pass the node of that item to the method. Replace item = null with something like const item = aras.getItemById("Part", "1234567890ABCDEF"); and then pass item.node as the second argument to aras.uiShowItemInFrameEx(). Make sure you have permission to access that item, and that it exists in the database.