Forum Discussion
change value of one field on the basis of other using spfx field customizer
- Sep 01, 2022
Hi LaxmikantB2
The below code should give you Security (choice column) value:
event.listItem["_values"].get("Security")
The result is as follows:
Please note, I am using SPFx v1.15.0
Hi LaxmikantB2
If you are using SPFx Field Customizer, then implement the onRenderCell with below logic
The method has signature as follows:
public onRenderCell(event: IFieldCustomizerCellEventParameters): void
Use below code to get the Security field value:
const securityValue = event.listItem["_values"].get("Security");
Once you get the item id, you can get the value of other field from same item.
Return the value as:
event.domElement.innerHTML = `<div>${securityValue}</div>`
- LaxmikantB2Aug 30, 2022Copper ContributorNanddeepNachan Have you got a chance to see this?
- NanddeepNachanAug 30, 2022Learn Expert
Hi LaxmikantB2
I will try to share the working code by coming Sunday. Bit away from laptop due to ongoing festive season. Sorry for that.
- NanddeepNachanSep 01, 2022Learn Expert
Hi LaxmikantB2
The below code should give you Security (choice column) value:
event.listItem["_values"].get("Security")
The result is as follows:
Please note, I am using SPFx v1.15.0
- LaxmikantB2Aug 27, 2022Copper Contributor
Hello Nanddeep,
Thanks for your reply...
What Will be inside the "_Values"?
currently my code look like this in .ts file:
public onRenderCell(event: IFieldCustomizerCellEventParameters): void {
const securityValue = event.listItem["_values"].get("Security");const conditionalFc: React.ReactElement<{}> =
React.createElement(ConditionalFc, { text } as IConditionalFcProps);ReactDOM.render(conditionalFc, event.domElement);
}
And in component .tsx filepublic render(): React.ReactElement<{}> {return (<div className={styles.conditionalFc}>{ this.props.text }</div>);}
I am getting error as :
Element implicitly has an 'any' type because expression of type '"_values"' can't be used to index type 'ListItemAccessor'.
Property '_values' does not exist on type 'ListItemAccessor'.