Service Portal -using Widgets server script insert incident using HTML button and auto populate fields

Akshay64
Tera Contributor

Hi All,

 

In service portal, when end user clicks on button/ link i need to create incident automatically and auto populate some fields using server side script. 

for this case i already written below function in widget's server script field and called from HTML 

***server script in widget***

function createIncident(){

var newincident=new GlideRecord("incident");
newincident.initialize();
newincident.assignment_group.setDisplayValue("ABC");
newincident.caller_id=gs.getUserName();
newincident.short_description="Test";
newincident.impact=1;
newincident.category='Other';
newincident.subcategory='pqr';
newincident.insert();
}

******** HTML body in Widget****

<a href="https://www.google.com" ng-click="createIncident()" target="_blank"> <p style="font-size:27px;"> Testing </p></a>

in above html code i have called createincident function using ng-click deirective.

But its not working incident is not created in incident table. Could please help me here how to call above server script in html so that on click of link in HTML it will create incident in the back end .

 

Thank you in advance

Regards,

Akshay

 

 

3 REPLIES 3

Anil Lande
Kilo Patron

Hi,

Please check below video, It will be helpful to learn and use logic to achieve your goal.

https://www.youtube.com/watch?v=ChTgHPTqNFU

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi,

Also check below link for similar solution:

https://community.servicenow.com/community?id=community_question&sys_id=30b1294bdbc0ab445ed4a851ca96...

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Thank you Anil!