Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2021 04:59 AM
Is there a way to make sn-record-picker field mandatory on the form.
I tried ng-required="true" and it is not working.
Solved! Go to Solution.
Labels:
- Labels:
-
Service Catalog
1 ACCEPTED SOLUTION

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2021 05:24 AM
You can do it via in the below method
Let's say below is the record pickert to select user's from user table
<div class="form-group">
<label>
<span style="padding-right: .25em" title="Mandatory" class="fa fa-asterisk mandatory" ng-class="{'mandatory-filled': c.username.value+'' != ''}"></span><abbr>${Requester Name}</abbr>
<i class="fa fa-check-circle" style="color: #21b384;" ng-if="c.username.value"></i>
<i ng-if="!(c.username.value)" class="fa fa-exclamation-triangle" style="color:#cc2114"></i>
</label>
<div class="input-container">
<span></span>
<sn-record-picker sn-model="c.username" sn-disabled="c.data.validator.empidReadonly" field="c.username" table="'sys_user'" display-field="'name'" display-fields="'email,user_name,u_local_name,u_local_department'" value-field="'sys_id'" search-fields="'name,user_name,u_local_name'" page-size="500" placeholder="Employee ID" default-query="data.hpavalidator.userQuery"></sn-record-picker>
</div>
</div>
<label>
<span style="padding-right: .25em" title="Mandatory" class="fa fa-asterisk mandatory" ng-class="{'mandatory-filled': c.username.value+'' != ''}"></span><abbr>${Requester Name}</abbr>
<i class="fa fa-check-circle" style="color: #21b384;" ng-if="c.username.value"></i>
<i ng-if="!(c.username.value)" class="fa fa-exclamation-triangle" style="color:#cc2114"></i>
</label>
<div class="input-container">
<span></span>
<sn-record-picker sn-model="c.username" sn-disabled="c.data.validator.empidReadonly" field="c.username" table="'sys_user'" display-field="'name'" display-fields="'email,user_name,u_local_name,u_local_department'" value-field="'sys_id'" search-fields="'name,user_name,u_local_name'" page-size="500" placeholder="Employee ID" default-query="data.hpavalidator.userQuery"></sn-record-picker>
</div>
</div>
sn-record-picker when the value is empty
In the above code check the CSS style which i have added (ng-class added)
sn-record-picker when the value is not empty ( when the value is filled it will show the field as shown below)
Also if you want to do the validation on Submit or any action Add the below code in the client controller
if (c.username.value == '' || c.username.value == undefined) {
//if the value is empty the control will reach inside this condition // add alert or error message
}
}
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2021 05:24 AM
You can do it via in the below method
Let's say below is the record pickert to select user's from user table
<div class="form-group">
<label>
<span style="padding-right: .25em" title="Mandatory" class="fa fa-asterisk mandatory" ng-class="{'mandatory-filled': c.username.value+'' != ''}"></span><abbr>${Requester Name}</abbr>
<i class="fa fa-check-circle" style="color: #21b384;" ng-if="c.username.value"></i>
<i ng-if="!(c.username.value)" class="fa fa-exclamation-triangle" style="color:#cc2114"></i>
</label>
<div class="input-container">
<span></span>
<sn-record-picker sn-model="c.username" sn-disabled="c.data.validator.empidReadonly" field="c.username" table="'sys_user'" display-field="'name'" display-fields="'email,user_name,u_local_name,u_local_department'" value-field="'sys_id'" search-fields="'name,user_name,u_local_name'" page-size="500" placeholder="Employee ID" default-query="data.hpavalidator.userQuery"></sn-record-picker>
</div>
</div>
<label>
<span style="padding-right: .25em" title="Mandatory" class="fa fa-asterisk mandatory" ng-class="{'mandatory-filled': c.username.value+'' != ''}"></span><abbr>${Requester Name}</abbr>
<i class="fa fa-check-circle" style="color: #21b384;" ng-if="c.username.value"></i>
<i ng-if="!(c.username.value)" class="fa fa-exclamation-triangle" style="color:#cc2114"></i>
</label>
<div class="input-container">
<span></span>
<sn-record-picker sn-model="c.username" sn-disabled="c.data.validator.empidReadonly" field="c.username" table="'sys_user'" display-field="'name'" display-fields="'email,user_name,u_local_name,u_local_department'" value-field="'sys_id'" search-fields="'name,user_name,u_local_name'" page-size="500" placeholder="Employee ID" default-query="data.hpavalidator.userQuery"></sn-record-picker>
</div>
</div>
sn-record-picker when the value is empty
In the above code check the CSS style which i have added (ng-class added)
sn-record-picker when the value is not empty ( when the value is filled it will show the field as shown below)
Also if you want to do the validation on Submit or any action Add the below code in the client controller
if (c.username.value == '' || c.username.value == undefined) {
//if the value is empty the control will reach inside this condition // add alert or error message
}
}