- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 08-06-2019 12:35 AM
table: u_products
fields; u_product -> string field containing names of the products, let products be - a,b,c,d,e
task: products must be unique (this can be done by checking the unique box in the dictionary settings no code needed)
________________________________________________________________________________________________
table: u_subscriptiontable
fields: u_company -> referring to core_company table and u_subscription -> referring to u_products table (not OOB)
(task: 1st record if company is TCS and product is a
2nd record if company is again TCS then products will only show b,c,d,e ( a will no longer be shown as its already selected for TCS) )
/* Write this in the advance ref qual part for the u_subscription field
javascript: new preventduplicatecompanyprod().myfunction(current.u_company);
*/
var preventduplicatecompanyprod = Class.create();
preventduplicatecompanyprod.prototype = Object.extendsObject(AbstractAjaxProcessor, {
myfunction: function(company)
{
var pr = new GlideRecord('u_products');
var sb = new GlideRecord('u_subscriptiontable');
var allprod='';
var ids;
sb.addQuery('u_company', company);
sb.query();
while(sb.next())
{
if(sb.hasNext())
{
allprod += sb.getDisplayValue('u_subscription')+',';
}
else
{
allprod += sb.getDisplayValue('u_subscription');
}
}
pr.addQuery('u_product', 'NOT IN', allprod);
pr.query();
while(pr.next())
{
ids += ','+pr.sys_id;
gs.log('Name:'+pr.u_product,'2312');
}
return 'sys_idIN'+ids;
},
type: 'preventduplicatecompanyprod'
});
________________________________________________________________________________________________
table: incident
task: Add a field u_subscribed this field refers to u_product table
in the incident table when we create a new record and select a caller ... lets say caller name is Rohan
Now we check were Rohan works- which is TCS ... so it will check u_subscriptiontable available products for TCS is a & b (Lets say those are 2 records present for TCS)
Then when we click the magnifying glass icon beside u_subscription field it will only show products a & b ... it will not be showing c,d & e as those products are not a part of TCS.
/* write this in the Adv Ref Qual part for the field u_subscription
javascript: new specificproduct().myfunction(current.caller_id.company)
*/
var specificproduct = Class.create();
specificproduct.prototype = Object.extendsObject(AbstractAjaxProcessor, {
myfunction: function(callerCompany)
{
var c = 0;
gs.log('The value of company is '+callerCompany,'$$$');
var arr = [];
var gr2 = new GlideRecord('u_subscriptiontable');
gr2.addQuery('u_company',callerCompany);
gr2.query();
while(gr2.next())
{
//c = c+1;
gs.log('Inside while ','$$$');
arr.push(gr2.u_subscription.sys_id);
//gs.log();
}
gs.log('The array content '+arr,'$$$');
return 'sys_idIN' + arr.toString();
},
type: 'specificproduct'
}); /* javascript:new preventduplicatecompanyprod().myfunction(current.u_company); */
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Mark as helpful if you guys found it worth any use.
Thanks,
Rohan.