1

I have 2 lists in the same site. One is configuration list with the data like below image and another list with the InfoPath form.InfoPath form dropdown values need to fill with the logged-in user related departments.

configuration list(multi user, string field types) is like:-enter image description here

0

InfoPath will allow you to get the Username. You could create a Rule with a "Username" conditional to setup your list values.

  • My list user field is a multi-user field. According to your condition :- domain\user1;domain\user2 = Username will not work. – Ganesha Feb 10 at 5:37
0

InfoPath forms are not supporting the filter the data by using the multi-user field. The alternative solution is Jqaury:- But we have 2 problems.

  1. Jquery will execute before InfoPath form load. :- Jquey setTimeout is the solution.
  2. InfoPath form partial postback will replace Jquery modifications:- So needs to check and refresh the dropdown control values frequently.

Jquery Code:-

<script>

$(document).ready(function(){
setTimeout(sample, 7000);
});

function sample() {
var select =  $('#DDLControlID')[0];


if(select.length>1) //check dropdown is available or not
{

if(select.length>100) //my requirement is 100 length. Control is identified with all fields/Partial postback replaced the my jquery changes 
{
 GetListDataAndSetDDL();
setTimeout(sample, 9000); // Call function again 
}
else
{
setTimeout(sample, 9000); // Call function again
}

}
else
{

setTimeout(sample, 3000); // Call function again

}

}

function  GetListDataAndSetDDL()
{
 var siteURL = _spPageContextInfo.webAbsoluteUrl;
 var listname = "ListName";  
 var currentUserId=_spPageContextInfo.userId;
 var url = siteURL + "/_api/web/lists/getbytitle('" + listname + "')/items?$select=ID,Title,MUserFieldName/ID&$filter=substringof('"+currentUserId+"',MUserFieldName/ID)&$expand=MUserFieldName/ID";    
$.ajax({
     url: url,
     method: "GET",
     headers: { "Accept": "application/json; odata=verbose" },
     success: function (data) {

        var items = data.d.results;      
     var select =  $('#DDLControlID')[0];

        for(var i = select.length-1; i > 0;i--) {       

             var itmExist=0;
             for (var j = 0; j < items.length; j++)
             {   
                 if(items[j].Title==select.options[i].text)
                  {
                     itmExist=1; 
                  }                
             }
          if(itmExist==0)
          { 
            $("#DDLControlID option[value='" + select.options[i].value + "']").remove();          
          }         
        }       
     },
     error: function (data) 
            {  
            alert("error");     
            }
 });
} 

</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.