I have a $$ViewTemplate with a button on the form (ButtonA). I’d like to click ButtonA programatically through a form action. If I simply add a form action button (ButtonB) the following JavaScript will click ButtonA:
document.forms[1].ButtonA.click();
My intent is instead to have ButtonB run an agent which calls a LotusScript Library that clicks ButtonA. Embedding the above JavaScript in the LotusScript does not accomplish this. I therefore ran the following alerts to determine the proper reference to the button from the LotusScript:
Print “alert(window.parent.frames[1].name);”
This returns ‘RightFrame’.
Print “alert(window.parent.frames[1].document.location);”
This returns ‘http://host/database.nsf/FormName?CreateDocument’
Based upon the above alerts, I expected that adding the following to the LotusScript would click ButtonA:
Print “<script language=”“javascript”“>”
Print “window.parent.frames[1].document.forms[1].ButtonA.click();”
Print “”
This results in a JavaScript error (object null or not found).
I’d appreciate any ideas on how to determine the proper reference to the button from the LotusScript?
Thanks.
Subject: Clicking a Button Programmatically
Is ButtonA actually in forms[1], or could it be living in forms[0] in the HTML?
Subject: RE: Clicking a Button Programmatically
ButtonA is defined on the second form of the $$ViewTemplate and should therefore be form[1]. (This is the CodeStore solution that uses two forms on a $$ViewTemplate to process selected docs.) If ButtonA is clicked manually, it creates a child window. The child window then copies values back to fields next to ButtonA with code that references form[1] as follows:
opener.parent.parent.frames[“RightFrame”].document.forms[1].elements[fieldName].value=“This is a test”;
Also, a form action (ButtonB) on the $$ViewTemplate can click ButtonA with the following code which also references form[1]:
document.forms[1].ButtonA.click();
To remove any doubt, I tried referencing form[0] instead, but this did not locate ButtonA.
Since the frame name and form have apparently been identified, it would therefore seem as if the following code should reference ButtonA from the LotusScript:
Print “<script language=”“javascript”“>”
Print “window.parent.frames[1].document.forms[1].ButtonA.click();”
Print “”
If you have any ideas on this, please let me know. Thanks.