Role based view switch does not run OnLoad code - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Role based view switch does not run OnLoad code

Last post 08-29-2007 09:59 AM by brandtsmith. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 08-23-2007 08:31 AM

    Role based view switch does not run OnLoad code

    I have a form that allows the user to click a btn and open another form...form2 is passed an input parameter (base don a field value in form1) and runs a sp via a webservice to refresh some secondary data...this happens during the OnLoad event...works fine

    Problem is that when I aplied role based logic to the form (Open form2 in a ReadOnly view for certain users) it apparently bypasses the OnLoad code...and therefore my secondary data source never updates...the ReadOnly view is NOT the default view.

    2 Roles : Reader (default) & Contributor

    Rule on open is to switch to ReadOnly view if users are in Reader role

    function XDocument::OnLoad(eventObj)
    {
    // Write your code here
    // Get the Input value
    var wVar = eventObj.XDocument.InputParameters["CourseID"].Value;
    eventObj.XDocument.UI.Alert("CourseID = " + wVar);

    // Get the DOM for the Seconday Data Source
    var dat = XDocument.DataObjects("GetCourseInfo").DOM;
    dat.setProperty("SelectionNamespaces", 'xmlns:sqlsoaptypes="http://schemas.microsoft.com/sqlserver/2004/SOAP/types" xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes" xmlns:s0="http://tempuri.org" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:ns1="urn:schemas-microsoft-com:sql:SqlRowSet1" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-08-16T13:30:52"');

    var xpath = "/dfs:myFields/dfs:queryFields/s0:GetCourseInfo/s0:CourseID";
    XDocument.GetDOM("GetCourseInfo").selectSingleNode(xpath).text = wVar;
    XDocument.DataObjects("GetCourseInfo").Query();
    }

     

    Filed under:
  • 08-23-2007 08:43 AM In reply to

    Re: Role based view switch does not run OnLoad code

    OnLoad View object is not created so you will get an exception if you try to use it. OnLoad to a set a view as default you need to use the following statement, replace "<viewName>" with your view name.

    XDocument.ViewInfos[<viewName>].IsDefault = true;

  • 08-23-2007 08:51 AM In reply to

    Re: Role based view switch does not run OnLoad code

    ??? I'm not setting the view using code...it's done in rules...

    are you saying to put XDocument.ViewInfos[<viewName>].IsDefault = true; in the OnLoad event??? 

    I just want the OnLoad to run regardless of which view is loaded...again that is controlled by Roles and Rules

  • 08-23-2007 09:07 AM In reply to

    Re: Role based view switch does not run OnLoad code

    If you are using rules then Onload code should run with out fail.

    Anyway you can set view in the onload and try out.

  • 08-24-2007 08:44 AM In reply to

    Re: Role based view switch does not run OnLoad code

    thats what I am saying...the OnLoad code does not run...wondering why?

  • 08-24-2007 09:46 PM In reply to

    Re: Role based view switch does not run OnLoad code

    If you can send me the XSN then I can try and investigate a little bit.

  • 08-29-2007 09:45 AM In reply to

    Re: Role based view switch does not run OnLoad code

    Apparently it has something to do with the Active Directory Security Group that the user is a membr of...not the Role in IP...I just encountered another example where I have a IP form that grabs an input parameter passed to it to get started...it absolutely will not run the OnLoad code if the js statement in boldface is present...when I comment it out it runs fine
    The user's security group is only User...member of Domain Users....admins seem to work fine?...

    function XDocument::OnLoad(eventObj)
    {
    // Write your code here

    var wVar = eventObj.XDocument.InputParameters["CourseID"].Value;

    wVar = 25
    eventObj.XDocument.UI.Alert("CourseID = " + wVar);

    // Get the DOM for the Seconday Data Source
    var dat = XDocument.DataObjects("GetCourseInfo").DOM;
    dat.setProperty("SelectionNamespaces", 'xmlns:sqlsoaptypes="http://schemas.microsoft.com/sqlserver/2004/SOAP/types" xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes" xmlns:s0="http://tempuri.org" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:ns1="urn:schemas-microsoft-com:sql:SqlRowSet1" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-08-16T13:30:52"');
    var xpath = "/dfs:myFields/dfs:queryFields/s0:GetCourseInfo/s0:CourseID";
    XDocument.GetDOM("GetCourseInfo").selectSingleNode(xpath).text = wVar;
    XDocument.DataObjects("GetCourseInfo").Query();

    }

  • 08-29-2007 09:59 AM In reply to

    Re: Role based view switch does not run OnLoad code

    nope...I'm developing on IP2007...other users are using IP2003...the execution stops when it executes

    eventObj.XDocument.InputParameters["CourseID"].Value

     

     

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