Read Only mode (file locking) - InfoPath Dev
in

InfoPath Dev

Read Only mode (file locking)

Last post 03-25-2009 05:32 AM by geoffc. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-24-2009 04:23 AM

    Read Only mode (file locking)

    Hi All,

    Environment:

    Info Path 2003 (soon will be redesigned to 2007) and SharePoint Server2007 library.

     

    SharePoint is locking files when opened by other users, that’s fine :), it even warns users that document will be opened in Read-Only mode.

     

    Is there any way to detect (e.g. on open) that document is opened in ReadOnly mode?

     

    I would like to disable submit buttons or even switch to ‘print view’ so users do not try to submit form when they cannot. Of course submit will fail with some nice warning, but the other actions happen like sending email notification or change of some fields locally that is mistaken to users.

      

    Thanks in advance,

     

    Greg.

      

     

  • 02-24-2009 03:59 PM In reply to

    Re: Read Only mode (file locking)

    Hi, and welcome...

    In C#, in your OnLoad (IP2003)

    thisXDocument.IsReadOnly

    Or in Loading (IP2007)

    this.ReadOnly

    Either of these return a boolean value of True if the document is read only and false if it is not. You could add a field to your form data source (or a secondary data source) and in your loading code you could set the value to true or false depending on whether the form is read only. Then you could base your conditional formatting off that field....

    Hilary Stoupa

  • 03-25-2009 05:32 AM In reply to

    Re: Read Only mode (file locking)

    This is what I did for now. I have the code setting a flag in the loading event if the form is in read only mode. I then have a field that displays "This form is in read only mode" and have buttons that hide if this flag is set to "Y" (conditional formatting). I found that a lot of users could not tell the difference between read-only and edit mode and were actually filling out the form in read-only mode. With SharePoint integrated forms, if the form is in read-only mode, it will only allow you to save it to your hard drive.  

    public void FormEvents_Loading(object sender, LoadingEventArgs e)

    {

    if (this.ReadOnly.Equals(true))

    {

    XPathNavigator mainData = MainDataSource.CreateNavigator();mainData.SelectSingleNode("/dfs:myFields/my:readOnly", NamespaceManager).SetValue("Y");

    }

    else

    {

    XPathNavigator mainData = MainDataSource.CreateNavigator();mainData.SelectSingleNode("/dfs:myFields/my:readOnly", NamespaceManager).SetValue("N");

    }

    }

    On a semi-related note, does anyone know how I can access the same code that is used for Word and Excel where if you try to open a document through SharePoint, it prompts the user to either select read-only or check out and edit?

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