0

I have a SharePoint online list which has a dropdown field called Approver. This approver dropdown should show the users whose Job Title is Vice President of respective dept.

For example, I am from the logistics dept. Hence I should see only the Vice President from the logistics department in the dropdown.

I have details of all user's departments, job title in SharePoint online user profiles, SQL Server DB.

Once the approver is selected, there should be an email sent to him on submitting the form.

Any technical advice on achieving this would be helpful. Thanks. Tried below code but get jquery error.

Failed to load resource....404 not found.

$(function () { var Dept=GetCurrentUserDept(); var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/SiteUsers?$filter=Title eq 'Vice President' and Department eq '"+Dept+"'"; //execute AJAX request $.ajax({ url: requestUri, type: "GET", headers: { "ACCEPT": "application/json;odata=verbose" }, async: false, success: function (data) { var userTitle=data.d.results[0].Title; alert(userTitle); }, error: function () { //alert("Failed to get details"); } }); }); function GetCurrentUserDept(){ var Dept=""; var requestUri = _spPageContextInfo.webAbsoluteUrl + "_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=Department"; //execute AJAX request $.ajax({ url: requestUri, type: "GET", headers: { "ACCEPT": "application/json;odata=verbose" }, async: false, success: function (data) { if(data.d.results.length>0){ Dept=data.d.results[0].Department; } console.log('My Dept is: ' +Dept) alert('My Dept is: ' +Dept) }, error: function () { //alert("Failed to get details"); } }); return Dept; }

Your Answer

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

Browse other questions tagged or ask your own question.