This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Updating an open form

markW - Friday, May 18, 2007 5:50 AM:

I have created a method which runs from clicking a button on an Item form.  Quite simple, it creates a new Item and then a relationship from the Item in the open form to the new Item.  The method works fine I just have one question.  After the method runs the open form does not automatically refresh(no real suprise) so I have to close the form and re-open to see the new relationship.  I have tried l clicking the refresh button in the menu, but that did not work.

My question:

Is there a way to refresh the data in the form programmtically from the method?

Actually this would apply for making any update from a client method on an open form. 

A secondary, question (which has other uses) is there a way to programmatically close the window from the method?  In an earlier forum question Rob gave me the command for the client API to open a form (which I have working), so I am guessing there is a close function also.  A save function would also be an option, I believe clicking on the save Icon leads to a screen refresh.

If it makes any difference I would not that I am currently running the method with the Form Item in View mode.

Regards,

Mark



PeterSchroer - Friday, May 18, 2007 8:05 AM:

Mark,

Just had a similar requirement earlier this week on a project in Germany.        In our case,  the client method was creating new Relationship instances,  so what we wanted was just the Relationships Grid (Tab) to repaint, at the end of the method.    The following one-line works,   displaying both any new relationship data found in the database  AND  any new relationships that your method added to the client cache that have not been saved yet.

 What this does is call the same function that the relationships grid tool bar Search button does.    We're simulating a user click of the refresh of the relationships grid area.

document

.frames[2].iframesCollection[document.frames[2].currTabID].contentWindow.doSearch(1);

 



RobMcAveney - Friday, May 18, 2007 10:03 AM:

Mark -

The call to close an item form is:

top.aras.uiCloseWindowEx(itemID);

Rob 



gaibwm - Monday, December 2, 2013 2:49 PM:

Pete,

 

I basically copied "document.frames[2].iframesCollection[document.frames[2].currTabID].contentWindow.doSearch(1);" and place it after my javascript where it create relationship. The code run from main form on click button

Below is the error reponse

 "Internal Error: event handler failed.Event handler failed with message: Unable to get value of the property 'IframesCollection': object is null or undefinedClient Side Error"



markW - Friday, May 18, 2007 4:21 PM:

Hello Rob,

Is the itemID the Item Id of the Form, or the Item within the form.  This is what I tried:

var windowitem = document.thisItem;

var windowitemid = windowitem.getID();

top.aras.uiCloseWindowEx(windowitemid);

Alas, it did not produce the desired results.

Or any result, for that matter.

My kung fu is very weak. :(

 

Any suggestions?

 

Mark

 



gaibwm - Monday, December 2, 2013 3:09 PM:

Just find out. "top" must prefix "document" namepace. I guess because I run from main form

top

.document.frames[2].iframesCollection[top.document.frames[2].currTabID].contentWindow.doSearch(1);



RobMcAveney - Friday, May 18, 2007 7:13 PM:

Hi Mark -

I am able to get consistent results with:

top.aras.uiCloseWindowEx(document.thisItem.getID());

but there are a couple things to watch out for.  First, it seems that putting code after the above can cause problems, likely because that code needs the window to remain open in order to run.  For example, if you put an alert('hi'); after the close command it will no longer work.  Second, it's important to realize that there is caching going on, so your code changes may not always be reflected immediately.  It's good practice to clear your Form cache (Tools->Admin->Clear Client Form Cache) after method changes to be sure the latest code is being run.

Rob 



RonCK - Monday, January 11, 2010 9:01 AM:

Rob & Pete, 

 

     Pete's method refreshes the relationship grid, is there a way to force a refresh of the main form?  I have a button on the main form that opens a popup window that will modify several fields on the parent form.  While I've had success manually updating the changed fields, I was wondering if it's possible to just refresh the whole form for the user.

 

thanks,

RonCK



Gorinich - Monday, May 23, 2011 1:41 AM:

I have the same problem with main form refreshing. Can anybody help?



fli - Thursday, July 21, 2011 4:30 PM:

I also need this.

I need the user to always open the item in "locked" state.

a client-side method, onformpopulate like (this.lockItem()) locks the item, but now I also need the main form refreshing call.

Help Please.



vladimior - Friday, June 21, 2013 10:35 AM:

I have similar problem. For it resolving I use next code

var res = top.aras.getItemById(itemTypeName, latestDocId, 0);
if (!res) return null;
    top.aras.updateInCacheEx(inDom, res);
if (win.updateRootItem)
    win.updateRootItem(res);

where latestDocId is Id of item to refresh.

It refreshes code but it has two issues:

  1. if you click on 'Lock' button of form, there will be opened new form with this item. So you will have two forms.
  2. in Search Grid of this type items you will see two same items.
So question still the same. How correctly update form with new item? Thank you for any solutions.