in servicenow , i have a table called blog_management and there is one string field in…
- User
in servicenow , i have a table called blog_management and there is one string field in that table named as title, my requirement is that i want to Warn the user if there is another blog with the same title similar to the Live demo. Create a Client callable Script Include (CCSI), call it from Client Script using GlideAjax.
- Assistant
- User
not working , while creating new record or updating the previous one, i didnt get any error message, my requirement is after changing the title from blank to any value it will show error message at a mean time,
- Assistant
- User
not working
- Assistant
- User
i wrote this script include warningExists: function() { var title = this.getParameter("sysparm_title"); var owner = this.getParameter("sysparm_owner") || ""; var current = this.getParameter("sysparm_current") || "-1";
var blog = new GlideRecord("x_snc_blog_mgt_blog_post"); blog.addQuery("title", title); blog.addQuery("sys_id", "!=", current); if ("" != owner) blog.addQuery("author", owner); blog.query(); if (blog.next()) { return blog.getValue("sys_id"); return "-1"; } },and client script
if (isLoading || newValue === '') { return; } g_form.clearMessages(); //Type appropriate comment here, and begin script below var blog = new GlideAjax("warningAjax"); blog.addParam("sysparm_name", "warningExists"); blog.addParam("sysparm_title", g_form.getValue("title")); blog.addParam("sysparm_owner", g_user.userID); blog.addParam("sysparm_current", g_form.getUniqueValue()); blog.getXML(sameBlog);
}
function sameBlog(response){ var sys_id = response.responseXML.documentElement.getAttribute("answer"); if("-1" != sys_id){ g_form.addErrorMessage('Warning: There is another ' +sys_id+ 'with this Title'); } else g_form.addInfoMessage("Good");
- Assistant
- User
working now and also , i need to Add a new method to CCSI and accept table name and other details to create a POC for Arbitrary GlideRecord. Refer the screenshot for sample code:
getToDoDetails: function() ( var table = this.getParameter("sysparm_table"); var sys_id = this.getParameter("sysparm_id"); var column = this.getParameter("sysparm_column"); var operation = this.getParameter("sysparm_operation");
if (operation == "read") ( var gr = new GlideRecord(table); gr.get(sys_id); return gr.getValue(column); else if (operation == "delete") t var gr2 = new GlideRecord(table); grz.get(sys_id); grz.deleteRecord(); ‣ else if (operation = "insert") t var gr3 = new GlideRecord(table); var columnl = this.getParameter("sysparm columnt"); var valuel = this.getParameter("sysparmn_valuel"); var column2 = this.getParaneter("sysparm_column2"); var valuez = this.getParameter("sysparm_value2"): gr3.initialize(); gr3.setvalue(column1, valuel); gr3.setvalue(column2, value2); gr3.insert(;
- Assistant
- User
for the above Author field we provide the Acl that only Author is able to see see their own record. now we need to bypass.
Make sure the ACLs on the Blog Post table is set to allow the blog authors to access only their own blogs. Bypass the ACL by calling the Script Include via GlideAjax. Run GlideAjax on Console. If you see GlideAjax is undefined, access /incident_list.do. Select gsft_main.do if you opened incidents in the main frame and run there.
- Assistant