GlideRelationship is not working in scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2023 09:51 AM
Hi Team,
I have cloned the OOB Data table widget in a scoped application, while doing the same I am gettting error "GlideRelationship is not working in scoped application" below is the snipped of code where this has been used.
if (data.relationship_id) {
var rel = GlideRelationship.get(data.relationship_id);
var target = new GlideRecord(data.table);
var applyTo = new GlideRecord(data.apply_to);
applyTo.get("sys_id", data.apply_to_sys_id);
rel.queryWith(applyTo, target); // put the relationship query into target
data.exportQuery = target.getEncodedQuery();
grRecord.addEncodedQuery(data.exportQuery); // get the query the relationship made for us
}
Kindly request to provide me a suggestion or a way where we can use the same in scoped application.
TIA
Regards,
Sivakumar M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2023 03:43 AM
Hi @Sivakumar10 ,
The GlideRelationship class is not available in scoped applications due to security restrictions. However, you can still implement relationship-based filtering using GlideRecord in a scoped application.
if (data.relationship_id) {
var rel = new GlideRecord('sys_db_object_relation');
rel.addQuery('child_table', data.table);
rel.addQuery('parent_table', data.apply_to);
rel.query();
var target = new GlideRecord(data.table);
var applyTo = new GlideRecord(data.apply_to);
applyTo.get("sys_id", data.apply_to_sys_id);
target.addQuery('sys_id', rel.getElement('parent') + '=' + applyTo.getUniqueValue());
data.exportQuery = target.getEncodedQuery();
grRecord.addEncodedQuery(data.exportQuery);
}
Can you give it a try with the above code.
Regards,
Shravan.
Please mark it as helpful if this helps you 🙂
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2023 10:39 PM
Hi @Sai Shravan ,
Thanks for the response.
While trying the mentioned script, I am not able to glide 'sys_db_object_relation' table as it is not available in the system.
Could you please suggest on the same.
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2023 11:59 PM
Hi @Sivakumar10 ,
I apologize for the mistake. It is sys_relationship
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2023 01:14 AM
Hi @Sai Shravan
No worries tried that as well. It is not listing the related records it just shows no record message.
I think this script is not querying the records.
TIA