How to access the UI page
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2024 10:29 AM - edited ‎11-26-2024 12:36 AM
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2024 08:20 PM
Hi @raj99918 ,
you can try something like this below to achieve this.
create field called reason , then create ui page called 'republish_reason_ui_page'
ui page
HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_sys_id" value="${RP.getWindowProperties().get('sys_id')}"/>
<input id="record_sys_id" type="hidden" value="${jvar_sys_id}" />
<div>
<h3>Enter Reason for Republish</h3>
<label for="reason_input">Reason:</label>
<textarea id="reason_input" name="reason_input" rows="4" cols="50"></textarea>
<br/>
<button type="button" onclick="updateArticle()">Update</button>
</div>
</j:jelly>
Client script :
function updateArticle() {
var sys_id = $j('#record_sys_id').val();
var reason =$j('#reason_input').val();
var grajax = new GlideAjax('KbUpdate');
grajax.addParam('sysparm_name', 'updateArticle');
grajax.addParam('sysparm_userId', sys_id);
grajax.addParam('sysparm_reason',reason)
grajax.getXMLAnswer(fetchvalue);
function fetchvalue(response) {
if (response) {
alert("reason updated");
}
}
GlideDialogWindow.get().destroy();
}
Script include : client callable script include
var KbUpdate = Class.create();
KbUpdate.prototype = Object.extendsObject(AbstractAjaxProcessor, {
updateArticle: function() {
var sysId=this.getParameter('sysparm_userId');
var reason=this.getParameter('sysparm_reason')
var kbArticle = new GlideRecord('kb_knowledge');
if(kbArticle.get(sysId)) {
kbArticle.u_reason = reason;
kbArticle.workflow_state = 'published';
kbArticle.update();
return "success";
}
return "failure";
},
type: 'KbUpdate'
});
ui action : script
function republish(){
var dialog = new GlideModal("republish_reason_ui_page"); // The name of your UI Page
dialog.setTitle("Enter Reason for Republish");
dialog.setPreference('sys_id', g_form.getUniqueValue());
dialog.render();
}
onclick condition :republish()
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2024 05:10 AM
what's your actual requirement?
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader