- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 10:39 AM
based on taxonmy topic , created record producer field in widget shows dropdown names
Below i written server script, how to fetch topic_id from portal url(esc?id=emp_taxonomy_topic&topic_id=77b83e4cc3203010069aec4b7d40dd54) and replace it in below code of topic=0ce0fe08c3203010069aec4b7d40ddde
i tried pass gc.addQuery('catalog_item', $sp.getParameter("topic_id") ); but this not working well
server script
(function() {
data.catalog_items=[];
var grRP=new GlideRecord('m2m_connected_content');
grRP.addEncodedQuery("catalog_item.sys_class_name=sc_cat_item_producer^topic=0ce0fe08c3203010069aec4b7d40ddde");
//grRP.addEncodedQuery("catalog_item.sys_class_name=sc_cat_item_producer");
grRP.query();
while(grRP.next())
{
var inc;
inc=grRP.getValue('catalog_item');
data.catalog_items.push(inc);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 11:19 AM - edited 10-20-2023 11:20 AM
Hi @Bhavani3, do you want to search items based on the topic, right?
You can enable AI Search for your instance.
Go to AI Search > AI Search Status
Enable AI Search
If you have a Utah instance, your employee center will have a search on the topic page
This is an Out Of The Box functionality
If my answer helped you, please mark my answer as helpful.
Vanderlei Catione Junior | LinkedIn
Senior ServicePortal Developer / TechLead at The Cloud People
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2023 06:41 AM
Hi @Bhavani3, If you really need to create a custom widget(I don't recommend because ServiceNow support only OOTB features ), you can try this
Server Script:
data.options = []
var grOptions = new GlideRecordSecure();
grOptions.addEncodedQuery();
grOptions.query()
while(grOptions.next()){
data.options.push({
name: grOptions.getDisplayValue(""),
id: grOptions.getValue("")
})
}
<select name="producers" id="producers-select" ng-change="c.redirect()" ng-bind="c.recordProducer">
<option value="{{option.id}}" ng-repeat="option in data.options">{{option.name}}</option>
</select>
Client
c.redirect = function(){
window.open("?id=sc_cat_item&id="+c.recordProducer)//replace the id for your Catalog item Page
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 08:59 AM
Hi @Vanderlei
in portal i created field name as "select record producer" dropdown
below table have "catalog item" field this is record producer and i want to display this catalog item dropdown value based on topic page in portal
Portal -based on topic id yellow highlighted then in record producer field displaying the values
html code
<div class="record" aria-hidden="true" ng-model="name">
Select Record Producer:
<sn-record-picker id="catalog_item" field="catalog_item"
table="'sc_cat_item_producer'"
display-field="'catalog_item'"
value-field="'sys_id'"
search-fields="'catalog_item'"
default-query="'taxonomy_topic.sys_class_name=topic'"
page-size="100"
></sn-record-picker>
</div>
<div class="submit-btn">
<input class="btn btn-primary btn-block" ng-click="c.submit(catalog_item)" type="submit" value="Submit">
</div>
client script
c.submit=function(curr_item) {
url="/esc?id=sc_cat_item&sys_id=" + curr_item.value;
var win = window.open(url, '_blank');
win.focus();
above code i working on it but still facing issue
issue what i facing
1.when select catalog item and submit the widget then it not redirect to record producer form in portal,Is it possible to make to redirect to record producer form?
2.based on topic_id i need to show field dropdown values in portal?
what server script code functionality i need to given?
can you please help me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 11:19 AM - edited 10-20-2023 11:20 AM
Hi @Bhavani3, do you want to search items based on the topic, right?
You can enable AI Search for your instance.
Go to AI Search > AI Search Status
Enable AI Search
If you have a Utah instance, your employee center will have a search on the topic page
This is an Out Of The Box functionality
If my answer helped you, please mark my answer as helpful.
Vanderlei Catione Junior | LinkedIn
Senior ServicePortal Developer / TechLead at The Cloud People
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 09:33 AM
Hi @Vanderlei
But I created custom widget for Record Producer dropdown field on each page of toipc portal, so Based on topic_id on each page Record Producer dropdown values needs to show.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2023 06:41 AM
Hi @Bhavani3, If you really need to create a custom widget(I don't recommend because ServiceNow support only OOTB features ), you can try this
Server Script:
data.options = []
var grOptions = new GlideRecordSecure();
grOptions.addEncodedQuery();
grOptions.query()
while(grOptions.next()){
data.options.push({
name: grOptions.getDisplayValue(""),
id: grOptions.getValue("")
})
}
<select name="producers" id="producers-select" ng-change="c.redirect()" ng-bind="c.recordProducer">
<option value="{{option.id}}" ng-repeat="option in data.options">{{option.name}}</option>
</select>
Client
c.redirect = function(){
window.open("?id=sc_cat_item&id="+c.recordProducer)//replace the id for your Catalog item Page
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 07:13 AM
Hi @Vanderlei
Thank you for the above code ,its really helpful me
small issue while submitting can you please help me on this ?
for above code i get output as name and thier sysid from data.options
{"name":"Request Relocation Assistance","id":"2c6295d53b422200d901655593efc43d"}
{"name":"Beneficiaries Inquiry","id":"edec71099f231200d9011977677fcf93"}
for this all id example-id--2c6295d53b422200d901655593efc43d i need to fetch this sysid automatically to url
url="/esc?id=sc_cat_item&sys_id="-----i givend in client script
but when i submit this shown as error message(You are either not authorized or record is not valid.) like https://dev84821.service-now.com/esc?id=sc_cat_item&sys_id=undefined
I want to achieve like below url like
https://dev84821.service-now.com/esc?id=sc_cat_item&sys_id=2c6295d53b422200d901655593efc43d-----when i given submit then it needs to show like this
in client script
<div>
{{data.options}}
<select name="catalog_item" id="catalog_item" ng-model="catalog_item" ng-required="true" class="form-control">
<option value="{{option.id}}" ng-repeat="option in data.options">{{option.name}}</option>
</select>
</div>
<div class="submit-btn">
<input class="btn btn-primary btn-block" ng-click="c.submit(catalog_item)" type="submit" value="submit">
</div>