none
infopath text box to make sure a name that is entered in a permissions list

    Question

  • I have now been asked to make a text box check to make sure that when the person filling out the form puts a managers name in the text box.

    I have a mangers list.

    What would be a good way to verify that the name entered in the text box is a manager?

    Can I do this with a rule?

    vendredi 6 juillet 2018 18:53

Toutes les réponses

  • Here you go,

    The code has to be placed as below

    https://sharepoint.stackexchange.com/questions/54043/validate-infopath-person-picker-against-sharepoint-list


    Please remember to click Mark as Answer on the answer if it helps you

    vendredi 6 juillet 2018 23:30
  • This is the code

    var nav = this.MainDataSource.CreateNavigator();
    
    //Obtain the Account Id from the people picker
    var userId = nav.SelectSingleNode("my:myFields/my:RequesterGroup/pc:Person/pc:AccountId", NamespaceManager);
    
    var web = SPContext.Current.Web;
    var userList = web.Lists["YOUR LIST HERE"];
    
    // Here I would use a CAML query instead, but works for the example
    foreach (SPListItem item in userList.Items)
    {
        var current = item["USER FIELD"] as SPFieldUserValue;
        var user = current.User;
    
        if(user.LoginName.equals(userId.Value))
        {
            // The user is part of the list, do something and return
        }
    }


    Please remember to click Mark as Answer on the answer if it helps you

    vendredi 6 juillet 2018 23:30

  • Hi cowboy2066,

    If the reply is helpful to you, you could mark the reply as answer. Thanks for your understanding.

    Best regards,

    Sara Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    lundi 9 juillet 2018 02:36
    Modérateur
  • Not using a people picker .

    lundi 9 juillet 2018 16:14
  • Not using a people picker for the text box since the text box is pulling data in from another list.
    lundi 9 juillet 2018 16:15
  • Not using a people picker for the text box since the text box is pulling data in from another list.

    Was looking for a possible InfoPath Rule to assist with this, as I have been trying to compare the name that is provided by the text box to the names in the validation list and nothing is working.

    I can not get this to work right :

    Name1 not equal manager

    Where Name1 is the name of the person,  it is coded to  appear  based on prior selections, but it can be entered manually  and then the name entered should be checked to see if it is in the verification list. if it is not in the list then an error message should appear ( using InfoPath Form Validation rule) stating this is "Not a Verifier Name."

    So far nothing works..  I have been trying to figure out why  with the name being in the verification list, that the  rule doesn't work.

    Tried contains,  not equal to  and still the validation still says that the name is not valid.
    even if the name is in the validation list.

    lundi 9 juillet 2018 16:24
  • Hi cowboy2066,

    We can achieve it in InfoPath form.

    We should add another field to show the result after comparing the name in the text box and the names in the validation list.

    We can follow the steps below:

    1. Add the fileld1 to display the compare result in the InfoPath form.

    2. Create the data connection from the validation list.

    3. And then in my InfoPath form, I will type the value in the title field and check if the value of the title field is in the list38.

    4. Set the rule in the title field. Select “Add Rule”->select “The Field changes”->”Query for data”->select “list38” in my environment.

    5. Then add another action “set a field’s value” in the title field. In the Field section, select “field1”.

    6. In the value section, like the two pictures below, and after all add the count like count( Title[Title = .] )>0.

    7. Set the validation rule on the field1 like the picture below.

    The result as below:

    There is a similar post:

    https://sharepoint.stackexchange.com/questions/231638/check-if-an-item-by-same-title-exists-in-sharepoint-list-then-display-that-info

    Best regards,

    Sara Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.



    vendredi 13 juillet 2018 09:28
    Modérateur

  • Hi cowboy2066,

    If the reply is helpful to you, you could mark the reply as answer. Thanks for your understanding.

    Best regards,

    Sara Fan

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    lundi 16 juillet 2018 01:35
    Modérateur
  • Does this need to be a validation comparison?

    If I understand your requirement, would it not ensure a manager is entered by creating a dropdown of the manager list to select one by the person filling out the form? Selecting "Cannot be blank" will make name selection mandatory.


    mercredi 18 juillet 2018 20:15
  • Hi cowboy2066,

    I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.

    If the issue was resolved, you can mark the helpful post as answer to help other community members find the helpful information quickly. 

    Best regards,

    Sara Fan

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    vendredi 20 juillet 2018 00:54
    Modérateur