locked
Getting a InfoPath 2003 fields value through code-behind in VBScript RRS feed

  • Question

  • Hello all,

     

    I’m currently developing a form with a comments system. I wanted to stop other users from amending or deleting other users comments unless they are Administrators to the form. I’ve managed to come up with a way of allowing Admins to amend or delete any comment but I can get the form to identify if the user is allowed to delete their own comments.

     

    I have a field that gets the current users login at start up and a field on each comment that stores the users’ username on the comment. How can I extract that data via the code behind to do a comparison?

     

    This is the code I've developed so far.

     

    Sub msoxd_my_repComments_OnBeforeChange(eventObj)		       
    
    		Dim currentUser
    
    		Dim commentAuthor
    
    		
    
    		
    
    		currentUser = "1"
    
    		commentAuthor = "2"
    
    		If xdocument.view.name <> "Admin View" then
    
    			If currentUser <> commentAuthor then
    
    				if eventObj.Operation = "Delete" then         
    
    					eventObj.ReturnStatus = false     
    
    					eventObj.ReturnMessage = "You cannot delete or edit comments. To get comments ammended please contact the RCR team."
    
    				end if 
    
    			End If
    
    		End If				
    
    End Sub
    
    

     


    Monday, May 23, 2011 9:24 AM

All replies

  • Managed to get half of the solution with the code below which gets the current users username. just need to work out how to get the comment authors name from a specific node in a repeating section.

    currentUser = XDocument.DOM.SelectSingleNode("/my:myFields/my:secUtilityValues/my:txtCurrentUser").text
    
    Monday, May 23, 2011 12:51 PM