How to use \$sp.getForm correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2017 11:50 AM
Hi Experts, I recently stumbled across this blog post - Portal diaries: Service Portal — Approval Summarizer in Portal that opened my eyes to the potential power of $sp.getForm. I want to use $sp.getForm to generate a form in a widget, but do not want to use the sp-model directive due to aesthetic requirements. I followed some examples for the following code:
var questionnaireGR = new GlideRecord("x_dnf_questionnaire");
questionnaireGR.query();
while (questionnaireGR.next()) {
data.questionnaireID = questionnaireGR.getValue("sys_id");
data.questionnaireModel = $sp.getForm("x_dnf_questionnaire", data.questionnaireID)._fields;
data.questionnaireSections = $sp.getForm("x_dnf_questionnaire", data.questionnaireID)._sections;
}
When i do a gs.addInfoMessage on data.questionnaireModel and data.questionnaireSections it provides me with all of the fields and form sections. Ideally I want to create a form on a front-end widget that ng-repeats through the form sections to populate the sections and then ng-repeats through the fields to create all the necessary fields. However, I'm a bit confused on how to do that in the html. For example, if I wanted to generate separate tabs for each form section, would it be something like this? Would the labels be generated with {{data.questionnaireSections.caption}}?
<md-tab ng-repeat="tabs in data.questionnaireSections track by $index" label="{{???}}">
I've noticed in some of the OOTB widgets that field-model is used, but I can't seem to find any documentations on how to use that either. Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 11:22 AM
Did you find an answer to this?