Announcing the Global SNUG Board of Directors. Learn more here

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Service Portal - SP Model

robertklimczak
Kilo Contributor

Where i can edit layout of sp-model?

<sp-model form-model="item" mandatory="allMandatory[item.sys_id]"></sp-model>

6 REPLIES 6

robertklimczak
Kilo Contributor

Found in other topic:


Hey Jason, the <sp-model> directive is included in the ServiceNow core code and unfortunately can't be changed as of now.

How can I pass a filter to the table while showing results from the table in sp-model



HTML code:


          <form>


              <sp-model form-model="::c.data.user" mandatory="::c.data.user._mandatory"></sp-model>                      


          </form>



Server Script :


data.user = {



"_fields" : {


"IO:user_field" : {


"refTable":"sys_user",


"sys_id":"",


"read_only":true,


"max_length":40,


"_class_name":"ReferenceQuestion",


"ed":{  


"reference":"u_employee",


"searchField":"name",


"qualifier":"",   // Do we give here , but in which format ? I need active employees only.


"name":"user"


}


}


},


"_sections" : [


{"columns": [


{


"fields" : [


{


"name" : "IO:user_field",


"type" : "field"


}


]


}


]


}


],


"_view":[


{


"name" : "IO:user_field",


"type" : "field"


}


],


"client_script":{


"onChange" : []


}


};




Thanks,
Sunil Singh




data.user = { "_fields" : { "IO:user_field" : { "refTable":"sys_user", "sys_id":"", "read_only":true, "max_length":40, "_class_name":"ReferenceQuestion", "ed":{   "reference":"u_employee", "searchField":"name", "qualifier":"", "name":"user" } } }, "_sections" : [ {"columns": [ { "fields" : [ { "name" : "IO:user_field", "type" : "field" } ] } ] } ], "_view":[ { "name" : "IO:user_field", "type" : "field" } ], "client_script":{ "onChange" : [] }


};






data.user = {



"_fields" : {


"IO:user_field" : {


"refTable":"sys_user",


"sys_id":"",


"read_only":true,


"max_length":40,


"_class_name":"ReferenceQuestion",


"ed":{  


"reference":"u_employee",


"searchField":"name",


"qualifier":"",


"name":"user"


}


}


},


"_sections" : [


{"columns": [


{


"fields" : [


{


"name" : "IO:user_field",


"type" : "field"


}


]


}


]


}


],


"_view":[


{


"name" : "IO:user_field",


"type" : "field"


}


],


"client_script":{


"onChange" : []


}


};


Constantine Kr1
Mega Guru

Customizations can be made (through an AngularJS "decorator" or by creating a clone of the directive). 

Please refer to this article:

Custom Layout for sp-model/spModel (Istanbul): https://community.servicenow.com/community?id=communi...

Audrey Deruere
Mega Expert

Hi,

 

Some answer here [work in London] :

You need to retrieve :

-sp_form_field.xml, sp_variable_layout.xml and sp_model.xml from your navigator :

find_real_file.png

and for each just copy the code in angular ng-templates tables with another name like mysp_form_field.xml, mysp_model.xml ...

 

Then you have to called your templates in a directive : 

Create 3 directives : myspModel, myspVariableLayout and myspFormField and copy this code that extend the initial directive (just adapt code for each directive) :

function(spModelDirective){

return angular.extend({},spModelDirective[0], {
templateUrl : 'mysp_model.xml'

});
}

 

Now you can modify each template to adapt your form.