Show Names in Reference Fields instead of IDs (On a task page)

  • 1
  • Question
  • Updated 1 year ago
  • Answered
Hi there, 

I did a review of our new Skuid layouts with my users yesterday. The good news is they are generally really stoked about the new pages. The less good news is they identified a lot of little issues that cause problems for them. It's just teething pains but just stuff I need to fix. 

All this is to say, apologies in advance for what may be a barrage of questions. 

Item # 1 -- on certain pages where I am passing in information via URL parameter or from another model, the reference fields are showing ID #s instead of the actual name. 



I have read in this thread that Skuid will look for that ID in a model and then try to find an associated "Name" field to display if possible. 

I have created a UserData model on this page with the User ID and Name included, but still the "Assigned to" field is displaying as an ID. I also have Owner.ID and Owner.Name included in the task model as well BTW. What am I doing wrong? 

Secondly, in the thread above Rob mentions that polymorphic fields like who/whatID are a bit different. 

So what can I do for these to ensure they get populated? 

Thanks!
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Hi Justin,

I believe that you should use the REFERENCE field and not the ID field.  For example, use Task.OwnerId not Task.OwnerId.Id.

Hope this helps.

Regards,
Irvin
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Great Questions. 

1. How to populate the Owner Name: 
You get owner name in several ways.  I do it by using 2 conditions.  
- First condition sets the Task OwnerID field to be the UserId of the user running this page. 
- Second condition sets the Owner.Name field to be the Name of the user running this page.   This second one is shown below: 



2. How to get name in What Id:
Here you need to follow the post you linked to above.  
- Make a "From Record" model that has a condition to be limited by URL parameter,  and includes the data you want prepopulated on the task.  In my case I made a "Opportunity" Model - thinking that the task would be related to the opportunity, and added Opportunity Name and ID fields. 
- Make a "Task Model"  with a condition that prepulates the What ID with the ID field from the "From Record" model.   In this case Skuid will find the ID and populate the text box with the name field value. 

You are on the right track.  And its true.  There are lots of little details required to get you accross the finish line.  Hopefully Skuid makes it easy to get things right. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
What about making this a dynamic solution? Can the whoid and whatid passed in through URL automatically create the relevant models via javascript?


That would be a slick little piece of code that could be used by a lot of people.


I'd do it if I could, but I'm at least 4 weeks away from having the chops to do this.
(Edited)
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Irvin, Pat, Rob -- thanks all for the responses. Much appreciated!

Rob, I am super close here. I have the "assigned to" name showing up correctly. Nice!

For WhoID/WhatID: 

I have set up the additional models and conditions as per your instructions. In my case, I am trying to make the page flexible for both leads and contacts (whoid) and accounts and opportunities (whatid). 

So I set up a "from record" model for each of these objects. 

These models populate based on either the "who_id" or "what_id" parameter that is passed in the URL from the button and stay blank if there is no match. 

Example for contact: 



Then on the task model, I have conditions to populate the WhoID or WhatID fields with the ID from the related model if that model has rows. 

You can't see them all but here is the contact rule showing



I then preview the page and this is the URL: 

https://skuid.na14.visual.force.com/apex/skuid__ui?page=TaskNew&who_id=003d000001rw7ZiAAI&wh...

As you can see, the "who_id" parameter is populated with a contact id (starts with 003) so the contact model should have rows, and so the task model condition should be sticking that ID in the Who ID field. 

Instead both Who ID and What ID are blank: 





I am probably missing something basic here. Let me know!
(Edited)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
We reproduced exactly what you are describing and its a bug in Skuid. 

But there is a workaround.  Make the conditions in the task model look for the URL parameter rather than look for the field from another model.   Have the condition be deactivated if the parameter is not provided.   Though there is not an explicit reference to the "from record" model - and therefore to the name field.  Under the covers Skuid says:  "Hey I've got this Id - is there a matching Name field anywhere in model data?  Ooh - its over here in this "from record" model -- I'll use it to make people happy!!!" 

Hope it makes you happy.  Figuring it out was a good end to my day.... 
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Rob, indeed seeing your message was a bright spot in my evening. And check it out!



Many thanks for helping me sort that one out!

P.S. @Pat, I am interested to know if your dynamic javascript model creation plan sees the light of day! 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb
I'm actually getting pretty close. Barry and Zach have been guiding me really well. I'm just prone to making mistakes I don't understand. :P

I've got it call up a popup with two of the page includes when my XML only has one and second empty popup. :S
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Ha I am about 4 years away from having the chops to do code this stuff. Good on you. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb
hehehe .... copy and paste .... reading and tinkering lots .... then hope someone can get you unstuck. Incrementally getting better after each block of code.
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
OK, encountering a tiny wrinkle here. I guess I'm not out of the woods yet. 

My new task page works beautifully in preview and all the conditions work. 

However, if I actually go to a contact and click "new task" the results are quite different. 

This is the link that I go to from the new task button, after going through the standard record type selection screen: 

https://skuid.na14.visual.force.com/apex/UI?ent=Task&RecordType=012d0000000SsrM&retURL=%2F00...

The URL contains a RecordType parameter as well as a who_id parameter. 

However, the actual page looks like this: 




The record type field is not respecting the URL parameter condition (in this case, it should be displaying "Call" as the record type) and the who ID is displaying the ID number again instead of the contact's name. 

Is it possible that this is not actually displaying the correct Skuid page? Do I need to create a custom "new task" button to direct it to the correct page? 

My understanding was that creating the visualforce redirect page and setting the page assignment in the Skuid admin would do the trick but now I'm not so sure. 



Thanks for the continued help :) 
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
BTW, the same thing is true of my "log a call" page, which creates a new row and populates it with defaults based on the who_id etc. 

In previewing the Skuid page, the IDs render as names like a charm. But actually going to a contact and logging a call the IDs display as IDs. 

In this the URL specifies the page to use and so I can confirm it is indeed the correct Skuid page. 

Super weird!

https://skuid.na14.visual.force.com/apex/ui?page=TaskLogCall&id=003d000001BujGZ&whatid=001d0...
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Hey Rob, just giving this a bump in case it was missed.

It is super strange I can't get this working on the live pages even though it works in preview. Hopefully I am missing something small. 

Thanks for any help. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
This is interesting. What Salesforce is doing when they run through the redirects is sending the 15 character ID.  Look for "what_id=###' in your url string to see this.   Skuid does not currently automatically look for the Name field associated with  the ID15 value.   (We are fixing this,  but it won't be ready for a while...) 

Ordinarily, we would tell folks to use the "field from another model" technique and add a specific condition to pull Name into the What.Name field.   But as we discovered above,  this would prevent you from being able to use multiple objects with the same page. 

Rock - Meet hard place. 

So,  either you can build separate pages for each object.  (Boo)  or you can build customer buttons on your record detail pages that don't use the salesforce overrides.  (Probably what we would reccomend).   You can pass record type in your query string, or let the user select from record types directly on the New Task page. 

Sorry this isn't more helpful. 
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Hey Rob, 

Thanks for the response. 

So just to make sure I am all clear -- 

If instead of the standard "new" action override, I create a custom "new" button that links directly to the page I want to use, then the functionality should work? 

Similar to

/apex/skuid__ui?page=TaskNew&whatid={!Account.Id}

Is this correct? 

And following this method would allow both the Who/What IDs to be translated into human-readable names AND ensure the record type parameter is respected? 

If so, a follow up question: 

If I want to preserve the choose record type functionality prior to creating the task, what are my options that will be compatible with this method? (This is of benefit because there are certain fields we only want to show based on the record type selected).  

I am guessing some kind of wizard on the page could mimic the standard choose record type dialogue, or....what about a drop down list directly on the detail page(similar to the table filter UI element) so folks can choose the record type directly and skip a screen? 

Something like: 

New Task (drop down) 
--- Call 
--- Email
--- General

etc. 

Possible? 

Thanks!
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
First question:  Custom Button for redirect. 
You are correct.  What I often do is simply preview the page,  copy that URL and put it in my custom button definition (and then replace the ID's with merge fields. 

Second question:  Record types. 
We'd suggest that you have record type be the first question on your page,  and then conditionally render the fields that only show up for particular record types.  Conditional renderning works client side,  so no page refresh would be needed, and users would on see the task fields they need to complete. 
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Thanks Rob. I will give this a crack and see how I go. 

Thanks again also for all your patience and help. I feel a bit bad posting all these questions -- am I having more trouble than other folks typically do? Or just unlucky? :) 

Anyhow thank you for the continued support. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
No worries.  Please do post your questions.  We'd rather hear the frustration and make the product better than have you simply struggle in quiet desperation... 
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Awesome answer. That's how we feel about our customer's feedback too. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
So, I'm tackling the very same thing in this thread.  https://community.skuidify.com/skuid/topics/dynamic-call-log-popup

I'll be making a page that is dynamic in the sense of the whoid and whatid. The whoid is no problem as it will be handled with a model for each kind of whoid. ContactWhoId and LeadWhoId.

As we have been tackling the whatid can be tricky in that it can be referencing any object. Will your "15 character" fix address the issue of not being able to show the Name field of the record?
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
15 or 18 char ID - you still need to have the actual Name in some model on your page so that it can be accessed.  If you control the origination of the task you can include the name in a URL parameter, and you can pass the 18 char id.  This is probably your best bet. 

Otherwize you probably need to determine the object type on the fly and create a model that gets ID and Name from the appropriate object.
Photo of hareesh achanta

hareesh achanta

  • 90 Points 75 badge 2x thumb
Hi Rob, I am facing a similar issue, where i am trying to prepolate the who id on the event creation page. I am seeing the 18 digit salesforce id. do we have any solution for that?
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
hareesh,

Make sure that you have the Who.Name field in your model.  Then when you set the WhoId (presumably an update row action) also set the Who.Name field.

Thanks,

Bill