New Record - Filter Available Record Types?

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I built a pop-up window that allows a user to create a case.  There is a picklist of the available record types for the user to choose from to determine the department they want to create a case for.  I want to filter the list of available case record types in the picklist, whats the best way to do that with Skuid?

Thanks!
Photo of Peter Herzog

Peter Herzog

  • 1,664 Points 1k badge 2x thumb
  • great about this support community!

Posted 4 years ago

  • 1
Photo of Peter Herzog

Peter Herzog

  • 1,664 Points 1k badge 2x thumb
Update: I am working with the contents of this post: https://community.skuidify.com/skuid/topics/how_do_i_render_custom_picklist_values

I created a simple snippet but it is not rendering a picklist, it creates a field that requires I type in the name:
        var field = arguments[0],
	value = skuid.utils.decodeHTML(arguments[1]);


        if (field.mode == 'edit') {
	     var picklistEntries = field.metadata.picklistEntries;
         

	picklistEntries.push(
		{ value: 'Tech Support', label: 'Tech Support', defaultValue:                 true, active: true  },
		{ value: 'Accounting', label: 'Accounting', 
                defaultValue: false, active: true }
	);
        }

skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
1) What do I need to do to make the page render a picklist rather than a text field?
2) Since this is the RecordTypeID field do I need to pass in the RecordTypeID?  Or should I use the RecordType.Name field?
(Edited)
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Check out this tutorial: http://help.skuidify.com/m/11720/l/214147?data-resolve-url=true&data-manual-id=11720 you need "skuid.ui.fieldRenderers['PICKLIST'][field.mode](field,value);"
Photo of Emily Davis

Emily Davis, Employee

  • 3,502 Points 3k badge 2x thumb
I may be interpreting your question incorrectly, but it looks like you may be able to get your picklist values without using a snippet.

If all you're trying to do is simply render your field as a picklist and limit the available picklist options, you can render your record type field as Picklist, then create a lookup filter on the record type field is not in the list of multiple specified values, and then list the names of the record types you don't want to include. 

Also, regarding part (2) of your question, RecordTypeId is a reference to the RecordType object. All record types in Salesforce fall into the RecordType object, and each has a field SobjectType which contains the name of Sobject to which the particular record type applies. So, like other reference objects in Skuid, the field uses an id to get another object, but it allows the user to look up an object by typing in its name, and it displays the field as the object's name.
(Edited)
Photo of Peter Herzog

Peter Herzog

  • 1,664 Points 1k badge 2x thumb
Moshe,

Thanks for your direction.  That helped!

Emily,

That is where I went first but it doesn't behave as I expected.  It wasn't removing the items I listed using the method you suggested and I couldn't determine why.  That's what drove me to use a Snippet.  Moshe's suggestion helped and I think I am going to proceed with that route for now.  I would prefer your route to avoid managing code.  
Photo of Emily Davis

Emily Davis, Employee

  • 3,502 Points 3k badge 2x thumb
A couple more tips (for future reference):

1) Make sure you're using the Name field on record type, not the DeveloperName.
2) You can also create a model on RecordType, with a condition that the SobjectType is "Case", and another condition that excludes the Names of particular record types. Then, your lookup filter would bring in only the values from the RecordType model.
(Edited)
Photo of Jack Sanford

Jack Sanford, Champion

  • 8,322 Points 5k badge 2x thumb
I've always had to choose the Name field specifically off the Record Type reference when doing Record Type filters. e.g. RecordTypeId.Name = 'Contacts'; if I try and do RecordTypeId = 'Contacts' it doesn't work - it's looking for the actual RecordTypeId.