OnLoad problem - InfoPath Dev
in

InfoPath Dev

OnLoad problem

Last post 05-14-2007 10:10 AM by liorlankril. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 05-14-2007 04:51 AM

    OnLoad problem

    I have an InfoPath Form that contain field (on main Data Source) named "UserLogin".

     On it's OnLoad event I do this code:

    function XDocument::OnLoad(eventObj)

    {

     var objNetwork = new ActiveXObject("WScript.network");

     var login=objNetwork.UserName ;

    if(XDocument.IsNew)

     {

    XDocument.DOM.selectSingleNode("/my:myFields/my:UserLogin").text=login; // Set the current user login as the value of "UserLogin"

    }

    else  // NOT NEW FORM

     {

           var existLogin=XDocument.DOM.selectSingleNode("/my:myFields/my:UserLogin").text;

          if (existLogin != login) 

          {

              //This is the problematic part !!!!!!!!!!!!!!!!!!!!!!!!!!

          }

        }  

    } 

     

    Explain: If the form is new form I update on the "UserLogin" field to be the value of the user login that open this form.

    If the form is NOT NEW - I check if the current user that open the form, is the same user that open it on the first time!!!!!!

     If not (the problematic part)..... I want to close the form or switch view but as I can see I cant do those operations on the OnLoad event!!!!!!

     

    What can I do?

    By the way I also try this: I add to my Data Source a boolean field called "AllowForm" (deafult value=True)

    In me code - In the (the problematic part) I write this:

    if (existLogin != login) { XDocument.DOM.selectSingleNode("/my:myFields/my:AllowForm").text=False; }

    And the I go to Tools-> Form Options-> Open and Save -> Rules -> Add -> Set condition: "if AllowForm is equal to False" -> Add action -> Switch to "View 2"

     

    It's not work because this open role happen before the OnLoad event so I AllowForm still =True!!!! and the action not operate!!!!

     

    Any Ideas????

  • 05-14-2007 05:19 AM In reply to

    • zaphi
    • Top 150 Contributor
    • Joined on 01-09-2006
    • Switzerland
    • Posts 82
    Hi liorlankril Try with "true" or "false" in quotation marks in your expressions. Regards Philippe
    Infopath 2007/SP2
  • 05-14-2007 05:43 AM In reply to

    Hi zaphi!

     

    Sorry, I didn't understamd your answer. What is "quotation marks in your expressions" ?

  • 05-14-2007 05:47 AM In reply to

    I try. "True/False" and "true/false" and even "0\1". That's not the problem:

     

    1) What can I do on OnLoad event - as I said I can't operate close form or switch view

    2) i try to add rule for open the form but it happens before the OnLoad event!!!

  • 05-14-2007 05:48 AM In reply to

    • zaphi
    • Top 150 Contributor
    • Joined on 01-09-2006
    • Switzerland
    • Posts 82
    Hi liorlankril I mean in your exemple { XDocument.DOM.selectSingleNode("/my:myFields/my:AllowForm").text="false"; } because you refer to a text field. Regards. Philippe
    Infopath 2007/SP2
  • 05-14-2007 05:53 AM In reply to

    hi zaphi. yes.... I did it, see me last reply befor your last one
  • 05-14-2007 08:26 AM In reply to

    You can use this in the OnContextChanged event: XDocument.View.SwitchView("Access Denied"); //Access Denied is the name of the second view
    Listen to Motörhead cos they play Rock'n Roll :)
  • 05-14-2007 10:10 AM In reply to

     

    Hi nukkumatti !

    OnContextChanged happen when  I change any input in the form...... That not good becuase the user who open the form (not new)  will be able to read the form, I even dont want him to be able to read it (only the user who open it as new form will be able to read it and write)

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.