spacer
cornerspacercorner
Reply
Frequent Advisor
DSmith
Posts: 37
Registered: 06-23-2010
0 Kudos
Accepted Solution

Posting back to Metastorm 9 from an external ASP.NET page hosted in an iFrame

 

In version 7.6 I was able to use the following code from an external page to post data back into  Metastorm

 

    parent.top.frames('eFormContents').document.getEle​mentById('FIELDNAME).value = NEWVALUE;

 

In version 9 when I test this with an alert it shows me the value being updated, but I do not see it update on the form and am then unable to take action against the new value.

 

The interesting thing is that the following click action does work

 

    parent.top.frames('eFormContents').document.getEle​mentById('BUTTONNAME').click();

 

Anyone doing a similar function and have it work in v9?

Advisor
jpesout
Posts: 11
Registered: 12-20-2010
0 Kudos

Re: Posting back to Metastorm 9 from an external ASP.NET page hosted in an iFrame

In M9, there is no longer the Metastorm element name and HTML id atribute the same. HTML ID is concatenated Metastorm name and some suffix, depending on element type (text, datetime, memo etc). But generated HTML is much more complex than that, so I wouldn' recommend to hack it. But if you will try, Firebug addon (or simillar in other browsers) can help you with that.

 

Frequent Advisor
DSmith
Posts: 37
Registered: 06-23-2010
0 Kudos

Re: Posting back to Metastorm 9 from an external ASP.NET page hosted in an iFrame

thanks.  Worked this out with Tony Wheeler in support today:

 

In v7

 

If you made a field memOnDemandData

 

You could post back to it with the following

 

Parent.top.frames('eFormContents').document.getElementById('memOnDemandData').value = "DeShoran Smith";

 

in v9 the name of the field only represents the Span so to actually post back or read the text the following is now needed

 

Parent.top.frames('eFormContents').document.getElementById('memOnDemandData_Editor_text').value = "DeShoran Smith";

 

So, for at least text fields you have to include _Editor_Text as the end of the field.

Occasional Contributor
Johhart
Posts: 6
Registered: 01-06-2012
0 Kudos

Re: Posting back to Metastorm 9 from an external ASP.NET page hosted in an iFrame

I have had a similar problem and posted a separate thread on the issue: (http://communitycentral.metastorm.com/t5/Metastorm-BPM-Version-9/Populating-a-textbox-in-v9-from-an-...)

 

I am trying to do the same but via opening a separate window from within Metastorm first using either window.open() or window.showModalDialog. I am not locked down to do it in that way, but I wouldn't know how to redesign the interface to add frames so I could then re-reference the parent (Metastorm) page. I have tried

window.opener.document.getElementById(

'txtHidden_Editor_text').value = "XXXX"; but this doesnt seem to work like it does with your format.

 

Obviously you have had some success in this field, so I just wondered if you could please give me some tips on how I might go about changing our design to do it like your (successful) way,

Employee
Tony Wheeler
Posts: 67
Registered: 05-02-2011
0 Kudos

Re: Posting back to Metastorm 9 from an external ASP.NET page hosted in an iFrame

Hi Jonhart,

 

If I understand correctly, it sounds like you are trying to programmatically interact with 1 open browser window from another window and I don't think this is possible. The web would be a very dangerous place if my website could enter fields and click buttons on another website without the user's knowledge.

 

The reason the technique described here works is because the iFrame shares a parent (the window object) with the metastorm form. There's even a school of thought that says this is too much interaction between an iFrame and its parent window object!

 

You may have success if your input is relatively simple and you use the window.showModalDialog(). You would not be "pushing" buttons from the dialog, however, you would be entering values and confirming the dialog and using the returnValue object of the modal dialog in the calling form. This would not be a separate form… this is a feature of the browser to get modal input.

 

var MyResponse = window.showModalDialog("subDoc.html",argsVariable, "dialogWidth:300px; dialogHeight:200px; center:yes");





//Assign MyResponse to some Metastorm fields with SetField(); After dialog confirmation, focus would return to the metastorm form and you would have to click the button

 

The other option would be to use a calculated label field to render an iFrame whose src attribute points to your custom form. In that case, you would be able to use the technique described above.

 

Occasional Contributor
Graham Field
Posts: 9
Registered: 06-17-2010
0 Kudos

Re: Posting back to Metastorm 9 from an external ASP.NET page hosted in an iFrame

I've used the Iframe pushing value into the V7.6 form

 

For V9, I've found it easier to pull the value from the iframe by running the following script in the client side script on submit.

 

This code pulls HTML text from a hosted HTML editor

 

function SaveHtml()
{
   var bodyField7 = GetField("tmpBodyField","");
   var frame = document.getElementById("HostFrame");
   var content = frame.contentWindow;
   var text = content.oboutGetEditor('_corresEditor').getContent();

   SetField(bodyField7,"", text);
   SetField("tmpTextChanged","","Yes");

   return true;
}

 

Cheers

Graham

Frequent Advisor
DSmith
Posts: 37
Registered: 06-23-2010
0 Kudos

update to this code, one for in iframe and one for external ASP.NET page (opened from metastorm)

//If your returning from an ASP.NET page hosted in a Metastorm from via an iFrame:

function ReturntoMetaStorm(DataObject) 

{
    //All forms in Metastorm are contained within a frame.  That Frame is called eFormContents
    //We will use a Generic MemoField named 'memOnDemand' - this field must exist on the Metastorm form in order to accept the value
  //This sets the value that Metastorm can use in Client Side Code
    parent.top.frames('eFormContents').document.getElementById('memOnDemandData_Editor').value = DataObject;
    //This sets the value that is updated on screen in Metastorm
    parent.top.frames('eFormContents').document.getElementById('memOnDemandData_Editor_text').value = DataObject;

    parent.top.frames('eFormContents').document.getElementById('btnSave').click();
   
}



//If your returning from an external ASP.NET page

function IReturntoMetaStorm(DataObject) {
//All forms in Metastorm are contained within a frame. That Frame is called eFormContents
//We will use a Generic MemoField named 'memOnDemand' - this field must exist on the Metastorm form in order to accept the value
/

window.opener.document.getElementById('memOnDemandData_Editor').value = DataObject;
window.opener.document.getElementById('memOnDemandData_Editor_text').value = DataObject;
window.opener.document.getElementById('btnRefresh').click();
self.close();

}
 

 

Frequent Advisor
DSmith
Posts: 37
Registered: 06-23-2010
0 Kudos

Re: update to this code, one for in iframe and one for external ASP.NET page (opened from metastorm)

Update -

After Installing the latest service release 9.1.2 with hotfix 2

 

The following no longer works for the post back from iFrames

 

parent.top.frames('eFormContents').document.getElementById('').value = DataObject;

 

I was able to locate the change and you should be able to use this instead if posting back from an iFrame fails after you update.

 

parent.top.frames.eFormContents.document.getElementById('').value = DataObject;

line spacer line
spacerFollow Metastorm on:
spacer Twitter YouTube Blog iTunes LinkedIn Metastorm Community Central, MC2
spacer Copyright © 2011 OpenText Corporation. All Rights Reserved.spacer About Metastormspacer Privacyspacer Legalspacer Site Mapspacer RSSspacer Contact Us
Microsoft Gold Certified Partner
Powered by Windows Azure
line spacer line