forcemula icon indicating copy to clipboard operation
forcemula copied to clipboard

Simple formula returning incorrect Field API name

Open phawthornffdc opened this issue 2 years ago • 2 comments
trafficstars

https://github.com/pgonzaleznetwork/forcemula/blob/867b26d0f2b4cf8d06c1610f5c2c216d0012fd89/src/index.ts#L63C1-L64C1

Simple formula

IF(Indicator__c, 0 - Total__c, Total__c)

Is producing an incorrect result. It is prefixing Total__c field with a 0, e.g. Account.0Total__c

Steps to reproduce:

import parse from 'forcemula';
const { json: { customFields} } = parse({
	parentObject: "Account",
	formula: "IF(Indicator__c, 0 - Total__c, Total__c)"
});

Current Behaviour:

customFields are returned as:

[ 'Account.Indicator__c', 'Account.0Total__c' ]

Expected Behaviour:

customFields should be:

[ 'Account.Indicator__c', 'Account.Total__c' ]

phawthornffdc avatar Oct 26 '23 14:10 phawthornffdc

Thank you @phawthornffdc ! Have you been able to identify where the issue is? I'm extremely busy these days so it'll be a few weeks before I can look at this. If you know where the issue is, that'll help.

pgonzaleznetwork avatar Nov 10 '23 10:11 pgonzaleznetwork

Hi @pgonzaleznetwork thanks for looking. I think the issue is on the line I referenced above, I "fixed" locally and it seems to work well but wasn't sure if there'd be any wider ramifications.

Fix was simply to check currentWord.length > 0 instead of currentWord.length > 1.

Thanks again

phawthornffdc avatar Nov 10 '23 10:11 phawthornffdc