Skip to main content
Nintex Community Menu Bar
Question

How can I create a lookup field to the userRole object

  • July 9, 2024
  • 9 replies
  • 48 views

Forum|alt.badge.img+20

Since I know this can’t be done since this object doesn’t allow for it, I’d like to fake this functionality in Skuid. I can create a text field called Role. I can create a custom field renderer. I can store the Role ID in the text field and render it’s Name in read mode and render a picklist in edit mode.

The question is how as I’m still rather novice when it comes to custom field renderers.

This topic has been closed for replies.

9 replies

Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

I’ve gotten this far, but some pointers would be appreciated. Please don’t give me the solution though. Going to the “else” bit now as I know how to do this part.

var field = arguments[0], value = skuid.utils.decodeHTML(arguments[1]), userRoleModel = skuid.$M('UserRoles'); if (field.mode == 'edit') { // lookup values in userRole in order to display then in a picklist } else { // find the Name of the userRole based on the value in the text field called Role and display name }

Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

Halfway there. 😃

var field = arguments[0], value = skuid.utils.decodeHTML(arguments[1]), $ = skuid.$, dfd = new jQuery.Deferred(), userRoleModel = skuid.$M('UserRoles'), currentUserRoleModel = skuid.$M('CurrentUserRole'), currentUserRoleModelCond = currentUserRoleModel.getConditionByName('roleId'); if (field.mode == 'edit') { // lookup values in userRole in order to display then in a picklist } else { // find the Name of the userRole based on the value in the text field called Role and display name currentUserRoleModel.setCondition(currentUserRoleModelCond,value); $.when(currentUserRoleModel.updateData()) .done(function(){ var currentURMRow = currentUserRoleModel.getFirstRow(); // set the value of the field skuid.ui.fieldRenderers.TEXT.read( field, currentURMRow.Name ); dfd.resolve(); }) .fail(function(){ dfd.reject(); }); } return dfd.promise();

Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

I think I got it.

  1. Create an array called userRolePicklist
  2. Loop through the rows in the userRole model
  3. Create an object for each row and push it into the array userRolePicklist
  4. update field.metadata.picklistEntries with userRolePicklist
Moshe, Barry, Irvin, anyone from Skuid dev? Right track?


Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

AWESOME!!! A text field that acts like a lookup field to an object that doesn’t allow lookups to it!!! 




Forum|alt.badge.img+18
  • 2192 replies
  • July 9, 2024

Pat…this thread makes me smile. Four posts of you answering your own question. 🙂


Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

hehehehe… I wasn’t willing to wait for the answer. 😉


Forum|alt.badge.img+9

Talking about arrays and objects like a real pro, no more javascript rookie!


Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

Getting there. Slow but sure.


Forum|alt.badge.img+17
  • Nintex Employee
  • 3766 replies
  • July 9, 2024

Well done Pat…