Widget Reference Field Helsinki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2016 05:38 AM
Hello Community,
Hopefully a very simple question here but I haven't found a solution yet so I figured I'd throw it out there while I'm still hunting. How do you create a reference field on a Widget in Helsinki? Since these aren't XML based, the Jelly syntax g:ui_reference is no longer an option.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2016 07:38 PM
Here is the code that generates it inside the service catalog:
<span class="ref-picker-container">
<div ng-if="field.value != ''" class="add-on">
<button type="button" class="btn btn-default bg-white lookup" ng-click="openReference(field)">
<span class="fa fa-info-circle"></span>
</button>
</div>
<div class="reference">
<sp-reference-element ref-table="formModel.table" ref-id="formModel.sys_id" field="field" glide-form="getGlideForm()" sn-disabled="field.isReadonly()" record-values="getEncodedRecordValues()" sn-select-width="100%"></sp-reference-element>
</div>
</span>
I tried to play a bit with it by exploring the data stored inside the field and formModel objects, however for the moment I still have not found out how to make it works. Not sure if it is at all possible as it calls "getGlideForm()" and "getEncodedRecordValues()" which I'm not sure would make any sense to try to include outside of a service catalog.
Just a path of solution that I thought might help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2016 09:16 PM
There is a directive in Service Portal widgets called <sn-record-picker> that will generate a field very similar to a reference field. You can pass in a table and various other properties which will allow user to pick a records based on the criteria you provide. It's pretty powerful. You can find an examples of how to use it by going to the list view of widgets and search the HTML field for "sn-record-picker".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 11:19 AM
Thanks Nathan. Is there a way to add a reference qualifier to these? I can't seem to find an instance of this. Is there any further documentation around using these yet?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 12:23 PM
I just did a tutorial around this directive, you can check it out here: Reference Fields with the snRecordPicker Directive - ServicePortal.io - Service Portal, CMS, and Cus...
You could use the 'default-query' property to limit the results based on your criteria, and in the controller you could dynamically construct the query based on your requirements.