I would like to select a query item and have that autofill text boxes related to that ad user.
Best Answer
-
Justin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭@Natisha_Ibokette - Middle name isn't available on System.Domain.User(or at least not in my lab), but First and Last are. I have an RO with a query prompt that targets a user and prompts underneath for 'First Name' and 'Last Name'. Using this bit of javascript in my custom.js file I'm able to populate the selection's First and Last into the prompts:On a side note, you might consider using the loadScript function in the code below. You can use it in your custom.js file to only run the above code when you're on the RO that you want to populate the name in. So you would save the above in a separate file in CustomSpace then the entry in custom.js(after the attached function) would look like:
$(document).ready(function(){ var kg = $('[data-role="grid"]').data("kendoGrid"); kg.bind('change', function(){ var di = kg.dataItem(kg.select()); var fn = $('.control-label:contains("First Name")').next(); var ln = $('.control-label:contains("Last Name")').next(); $(fn.children()[2]).val(di.FirstName).keyup(); $(ln.children()[2]).val(di.LastName).keyup(); }) })
loadScript('/CustomSpace/populateNameFields.js',["beca7b88-fb26-892c-40c3-5a7fbac7dd50"]);
but you would replace beca7b88-fb26-892c-40c3-5a7fbac7dd50 with the GUID of your specific RO.
I hope this helps!
(PS. Shout to @Geoff_Ross for the script loader)/* ----------------------------------------------- */ /* ---------------- Script Loader ---------------- */ /* ----------------------------------------------- */ // This helps with loading scripts and debugging // Pass in the path of the js file and an array of url segments on which to run this code // EG loadScript("/CustomSpace/CustomExtension/CustomExtension.js",["ServiceRequest","Incident"]); var loadScript =function (path,urls) { urls.forEach(function(url) { if(window.location.href.indexOf(url) !==-1){ // Verify we are on the valid page var result = $.Deferred(), script = document.createElement("script"); script.async ="async"; script.type ="text/javascript"; script.src = path; script.onload = script.onreadystatechange =function(_, isAbort) { if (!script.readyState || /loaded|complete/.test(script.readyState)) { if (isAbort) result.reject(); else result.resolve(); } }; script.onerror =function () { result.reject(); }; $("head")[0].appendChild(script); console.log("Loaded "+ path) return result.promise(); } }) }; /* ----------------------------------------------- */ /* -------------- END Script Loader -------------- */ /* ----------------------------------------------- */
6
Answers
but you would replace beca7b88-fb26-892c-40c3-5a7fbac7dd50 with the GUID of your specific RO.
I hope this helps!
(PS. Shout to @Geoff_Ross for the script loader)