How to add unique ID's for lightning input of type toggle active and inactive - salesforce

I am using the below code to display the toggle button with active/inactive texts. But for automation testing purpose I need to add unique id/attribute for active and inactive individually. By using the below format, I can see both active and inactive in console.
Can anyone help me with this please?
<lightning:input type="toggle" checked="{!item.IsActive}" onchange="{! c.handleChange }" messageToggleActive="Active" messageToggleInactive="inactive"/>

Related

onChangeListener for lookup field is not getting Fired in Lightning Record Edit Form

I am trying to access the keywords typed in a lookup or master-detail field in lightning-record-edit-form using lightning-input-field and based on the value entered in that lookup I want to update picklist value to active or Inactive. Below is the code
<template>
<lightning-card>
<lightning-record-edit-form object-api-name="Opportunity_Bidder__c">
<lightning-input-field field-name="Opportunity_Name__c" onchange={onOpportunitySelected}>
</lightning-input-field>
<lightning-input-field field-name="Bid_c" onchange={onOpportunitySelected}>
</lightning-input-field>
<lightning-button type="submit" variant="brand" label="Create"></lightning-button>
</lightning-record-edit-form>
</lightning-card>
onOpportunitySelected(event){
alert('alert called');
this.opportunityName = event.target.value;
}
The issue is that onOpportunitySelected method is not called when user is typing in Opportunity_Name__c. However, its being called on other fields like textfield or any other field than lookup or master-detail field
I am new to salesforce, can anybody tell me that is it achievable using lightning-input-field for lookup or I need to customize lookup like here
To re-iterate "OnChange wont work on Lookup or Master-Detail fields in Lightning-record-edit-form ?"
Thanks in Advance

react select drop down on change Issue in the edit mode

I am currently using react-select library to my project
react-select
This is my create invoice page, Please check below view,
When user select the PO drop down, red colored text boxes are automatically filled. It is working well.
This is my invoice list page view
When user click the action button, data passed and redirect to the create invoice page. Currently object passed and PO number set correctly. but other fields did not filled automatically.
PO NO is set correctly. But on change function did not fired and did not set other text box values.
This is my drop down and onchanges function.
<Select
options={options}
value={values.purchaseOrderNumber}
onChange={onChange} onFocus={onChange}
name="purchaseOrderNumber"
/>
const onChange = (selectedOP) => {
setInputValue(selectedOP);
loadselectedValue(selectedOP);
//handleChange(selectedOP);
console.log(selectedOP);
};
I know this codes not enough to give better solution. but if you can please tell me the correct path to do this using react hooks. thanks

unable to reset the af:query panel search fields after page navigation

I've created a search page using default Named Criteria. I'm able to search and reset the search fields while being on the page. If I navigate to another page without clearing the search fields, the previous values are getting stored in the fields and unable to clear the fields with the reset button.
<af:query id="qryId1" headerText="Search" disclosed="true"
value="#{bindings.ImplicitViewCriteriaQuery.queryDescriptor}"
model="#{bindings.ImplicitViewCriteriaQuery.queryModel}"
queryListener="#{bindings.ImplicitViewCriteriaQuery.processQuery}"
queryOperationListener="#{bindings.ImplicitViewCriteriaQuery.processQueryOperation}"
resultComponentId="::resId1" rows="2" maxColumns="3"
runQueryAutomatically="searchDependent"
saveResultsLayout="never" clientComponent="false"
contentDelivery="immediate" immediate="true"/>

With Semantic UI React, how to build a tag input similar to Stack Overflow's?

I'm interested in building a Tag input feature like Stack Overflow where the feature set includes:
Input field which has a autocomplete feature (takes user input, fetches results from the server and displays those results to the user for easy selection.
Input field contains 1 or more selected items as tags.
Suggestions outside of the input which when clicked have the results added to the input field.
Screenshots from Stack Overflow:
I'm using Semantic-UI-React and notice there is a search component which could work: https://react.semantic-ui.com/modules/search
It does not appear that this Semantic-UI-React search component allows for adding more than one result or adding results via a method outside of the input. Am I missing something?
Should I use Semantic UI for this feature or will I need to build this entirely from scratch in my React app?
It's not properly highlighted in the react semantic-ui dropdown documentation but the allowAdditions field will enable tagging capabilities:
<Dropdown search selection multiple allowAdditions />
You need to add the onAddItem prop to update the options list. In here, I did this:
<Dropdown
placeholder='Select Friend'
fluid
search
selection
multiple
allowAdditions
onAddItem={(event, data) => friendOptions.push({key: data.value, text: data.value, value: data.value})}
options={friendOptions}
/>
And now you can add items to the dropdown list.

Google tag manager button reference

I'm trying to get google tag manager to track a couple of different buttons on a site. We're currently unable to change the site to aid with this, so we have to find a solution solely with tag manager.
There are several buttons on the site all with the same format as to the two below.. they all have "submit" as the type and a unique term for value so I'm trying to use the tag manager Form Listener which picks up on type="submit". Is there any variable I can use to pull the value field into my event so I can create individual goals in analytics?
etc etc
Any help is greatly appreciated.
You can use built-in variable "Click Element", then create custom JS-variable:
function(){
try{
return {{element}}.getAttribute("value"); //I am not sure now if it is {{element}} or {{Click Element}}
}catch(err){}
}
This will give you a value attribute of clicked button.
Maybe a useful link by Simo Ahava:
http://www.simoahava.com/analytics/track-form-engagement-with-google-tag-manager/#3
You can use built-in auto-event variable Element Attribute to get value. And be sure to use click tracking and not form tracking, because you want to track button clicks and not form submissions.

Resources