Illegal circular reference

I work on some product numbering. A deal is linked with the product hierarchy on different levels. Structure is: Topic - Category - Package | Product
I build some code which runs through all those relations and picks the calculated number (blue) in the style of 1.2.3 . Each level adds a number to the parent number.

However my code doesnt work:

const topics = [
	...(@All of Topic Number || []).map(v => v.split('.')[0]),
	...(@All of Category Number || []).map(v => v.split('.')[0]),
 	...(@All of Package Number || []).map(v => v.split('.')[0]),
	...(@All of Product Number || []).map(v => v.split('.')[0]),
].filter(Boolean);

const uniqueSorted = Array.from(new Set(topics)).sort((a, b) => Number(a) - Number(b)).join(',');
uniqueSorted;

Sample preview:
A circular dependency was detected: Topics → Product Number → Category Number. Please adjust your script to remove this circular dependency.

I’m not sure if I mis understand the circular reference, but I guess it isn’t one. I just pull the calculated values from each level.

My Workaround is adding another calculation field at category level, which directly pulls the parent topic number.

const topics = [
	...(@All of Topic Number || []).map(v => v.split('.')[0]),
	...(@All of Category Topic Number || []).map(v => v.split('.')[0]),
 	...(@All of Package Number || []).map(v => v.split('.')[0]),
	...(@All of Product Number || []).map(v => v.split('.')[0]),

].filter(Boolean);
const uniqueSorted = Array.from(new Set(topics)).sort((a, b) => Number(a) - Number(b)).join(',');
uniqueSorted;

The only difference now is, that the calulation of Category Topic Number in the category record is

@All of Topic Number[0]

instead of accessing still existing Category Number which is calculated:

@All of Topic Number[0] + "." + @Number

Could it be, that the detection of the circular reference is wrong in this case?

1 Like

Again I hit this “illegal circular reference” … and I believe I found the reason.

  1. I have 4 different relations to fields in the relationship field
  2. Some of the fields are calculation fields, that referre to the same field
const topics = [
...(@All of Topic Number || []).map(v => v.split('.')[0]),
...(@All of Category Number || []).map(v => v.split('.')[0]),
...(@All of Package Number || []).map(v => v.split('.')[0]),
...(@All of Product Number || []).map(v => v.split('.')[0]),
].filter(Boolean);

const uniqueSorted = Array.from(new Set(topics)).sort((a, b) => Number(a) - Number(b)).join(',');
uniqueSorted;

Product Number and Package Number are calculation fields, that also contain a relation to the Category Number

1 → Topic Number
1.2 → Category Number (consists of topic number and individual given number)
1.2.3 → Package / Product Number (consists of category number and individual given number)

So there is no “circular reference” - its just a second way to the same field.
Can a calculation field not handle this currently?

I found a second bug, when I tried to uncomment. The “illegal circular reference” was still detected.

const topics = [
...(@All of Topic Number || []).map(v => v.split('.')[0]),
...(@All of Category Number || []).map(v => v.split('.')[0]),
// ...(@All of Package Number || []).map(v => v.split('.')[0]),
// ...(@All of Product Number || []).map(v => v.split('.')[0]),
].filter(Boolean);

const uniqueSorted = Array.from(new Set(topics)).sort((a, b) => Number(a) - Number(b)).join(',');
uniqueSorted;

Only when I deleted those lines, the error was gone:

const topics = [
...(@All of Topic Number || []).map(v => v.split('.')[0]),
...(@All of Category Number || []).map(v => v.split('.')[0]),

].filter(Boolean);

const uniqueSorted = Array.from(new Set(topics)).sort((a, b) => Number(a) - Number(b)).join(',');
uniqueSorted;

I could also have deleted the Category Number line to solve the error. So its clearly the parallel paths:

  • to the category number field, which I need from the linked categories and
  • to the Package / Product number field, which contains the category number in the calculation field.

Hope its now easier to understand?

1 Like

I’ve run into this as well.

My solution was to create a duplicate text field, and copy the value to it with automation. Then call the duplicate elsewhere.

It’s definitely not idea or a good practice BUT it did get us where we were going.

2 Likes