Reference field values are not visible in Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 09:46 PM
I have an HR Service (Scope - Human Resources: Core) in the ESC Portal.
I have created a custom table "Routing ID" in Global scope which extends CMDB CI Table.
I have a variable in the HR Service which is referenced to the custom table. I have records in the custom table but still I am unable to see any records from the Portal. It says "no matching records found"
I have given the custom table Read ACL to my user, and also given the cmdb_read role to my user, still the same issue.
Please let me know what I can check to get this fixed.
Thank you.
- Labels:
-
Employee Service Center
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Ranjit,
Did you get the solution for this? I am also facing the same issue . In portal, values are not populating for reference field. If you got the solution, pls post here. That would be very helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Per creare Application Access:
- Vai a: System Applications > Application Cross-Scope Access
- New
- Source Scope: Human Resources: Core (sn_hr_core)
- Operation: Read
- Target: Seleziona la tua tabella custom u_routing_id
- Status: Allowed
3. Verifica la Variabile del Catalog Item
// Controlla la configurazione della variabile // Service Catalog > Catalog Variables // Parametri da verificare: // - Type: Reference // - Reference: u_routing_id (tua tabella custom) // - Reference qualifier: (lascia vuoto per ora) // - Read roles: (verifica che sia vuoto o compatibile)
4. Verifica i Record nella Tabella
Esegui questo script in Background Scripts:
// Verifica che i record esistano e siano accessibili var gr = new GlideRecord('u_routing_id'); gr.query(); gs.info('Total records in u_routing_id: ' + gr.getRowCount()); while (gr.next()) { gs.info('Record: ' + gr.sys_id + ' - ' + gr.getDisplayValue()); } // Verifica se l'utente può leggerli var userName = 'nome.utente'; // Sostituisci con il tuo username gs.info('User can read: ' + gr.canRead()); // Impersona l'utente e riprova var user = new GlideRecord('sys_user'); user.addQuery('user_name', userName); user.query(); if (user.next()) { var impersonator = new GlideImpersonate(); impersonator.impersonate(user.sys_id); var testGr = new GlideRecord('u_routing_id'); testGr.query(); gs.info('Records visible as ' + userName + ': ' + testGr.getRowCount()); impersonator.unimpersonate(); }
5. Verifica Dictionary Entry
// Vai a: System Definition > Dictionary // Cerca: u_routing_id // Verifica che il campo display (name o altri) sia: // - Active: true // - Read only: false
6. Controlla Reference Qualifier sulla Variabile
Se hai un reference qualifier, potrebbe filtrare troppo:
// Nella variabile, controlla: // - Reference qualifier: // Se presente, prova a rimuoverlo temporaneamente // Oppure usa: javascript: 'active=true'
7. Verifica CMDB ACL (Parent Table)
Dato che la tua tabella estende cmdb_ci:
// Background Script per verificare var gr = new GlideRecord('u_routing_id'); gr.setLimit(1); gr.query(); if (gr.next()) { gs.info('Can read CMDB CI: ' + new GlideRecord('cmdb_ci').get(gr.sys_id)); gs.info('Has cmdb_read role: ' + gs.hasRole('cmdb_read')); gs.info('User roles: ' + gs.getUser().getRoles()); }
8. Clear Cache
A volte il problema è solo cache:
- Vai a: System Diagnostics > Cache Inspect
- Cerca: u_routing_id
- Flush della cache
- Oppure: cache.flush nella cache
9. Soluzione Rapida - Script da Eseguire
Esegui questo script in Background Scripts per configurare tutto:
// === CONFIGURAZIONE AUTOMATICA === var tableName = 'u_routing_id'; // Nome della tua tabella var hrScope = 'sn_hr_core'; // Scope HR // 1. Crea/Aggiorna ACL di Read (Public) var acl = new GlideRecord('sys_security_acl'); acl.addQuery('name', tableName); acl.addQuery('operation', 'read'); acl.query(); if (!acl.next()) { acl.initialize(); acl.setValue('name', tableName); acl.setValue('operation', 'read'); acl.setValue('active', true); acl.setValue('admin_overrides', true); acl.setValue('description', 'Auto-created for portal access'); acl.insert(); gs.info('ACL created'); } else { gs.info('ACL already exists'); } // 2. Crea Application Cross-Scope Access var appAccess = new GlideRecord('sys_scope_privilege'); appAccess.addQuery('source_scope.scope', hrScope); appAccess.addQuery('target_name', tableName); appAccess.addQuery('operation', 'read'); appAccess.query(); if (!appAccess.next()) { var hrScopeGr = new GlideRecord('sys_scope'); hrScopeGr.addQuery('scope', hrScope); hrScopeGr.query(); if (hrScopeGr.next()) { appAccess.initialize(); appAccess.setValue('source_scope', hrScopeGr.sys_id); appAccess.setValue('target_name', tableName); appAccess.setValue('target_type', 'sys_db_object'); appAccess.setValue('operation', 'read'); appAccess.setValue('status', 'allowed'); appAccess.insert(); gs.info('Application Access created'); } } else { gs.info('Application Access already exists'); } // 3. Verifica record var count = new GlideRecord(tableName); count.query(); gs.info('Total records in table: ' + count.getRowCount()); gs.info('=== CONFIGURATION COMPLETED ==='); gs.info('Clear cache and test again');
10. Test dal Portal
Dopo aver applicato le fix, testa:
- Logout/Login dal portale
- Apri il HR Service nel portale
- Prova la variabile reference
- Se ancora non funziona, apri Developer Tools (F12) e controlla la Console per errori JavaScript
