how to differentiate Between 2 identical action

ahmedt
Tera Contributor

Hello All,
I have a problem with default component ,if i have 2 of same component in the custom component they both fire the same action with the same payload so i can not tell the difference between them 

Example:

import { createCustomElement, declarativeOperations } from '@servicenow/ui-core';
import snabbdom from '@servicenow/ui-renderer-snabbdom';
import '@servicenow/now-toggle';
const view = (state, { updateProperties, updateState }) => (
	<div>
	
		<now-toggle data-field="email" id="masadjaskld"/>
		<now-toggle data-field="notifications"/>
	<button on-click={e => updateState({
		path: 'math',
		value: 2,
		operation: declarativeOperations.SET
	})}>Hello !</button>
	<p>{JSON.stringify(state)}</p>
</div>
);

createCustomElement('my-element', {
	renderer: { type: snabbdom },
	view,
	properties: {
		name: { default: 'Fred' }
	}, setInitialState() {
		return {
			animals: {
				cats: 1,
				oo: { mn: "rec" }
			}
		};
	},actionHandlers:{
		'NOW_TOGGLE#CHECKED_SET': {
			effect(coeffects
			) {

  
			}
		}
	}
});

 I tried by DOM variables but i can not get the DOM element from the action 

3 REPLIES 3

Tanushree Maiti
Kilo Patron

Which kind of component it is . In Portal , component id should be unique.

 

Within ServiceNow , all component having unique sys_id. So instead of calling the component with other attribute like component's name , try with sys_id.

 

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Dinesh_Now
Tera Guru

Hello @ahmedt .

@Tanushree Maiti already responded to you.

i want to add some article please refer that, it may be help u.

https://www.servicenow.com/docs/r/yokohama/platform-administration/c_UniqueRecordIdentifier.html?con...


Please mark this response as Helpful & Accept it as solution if it assisted you with your question.

ahmedt
Tera Contributor