Set object to null

I am trying to null object.

In schema X I have link to schema Y… This link is showing string of few values.

I have tried

doo.model.xxx.value = null

or

var AB = doo.model.xxx.value
AB.length = 0

Is there any way to delete values from linked field?

Hi Thomas,
We are working on simplifying the lookup value setup.
If you need it now, please use this workaround:

if (doo.model.xxx.value.id) {
  doo.model.xxx.value = { id: null, originalId: doo.model.xxx.value.id, _$$changed: true }
}

Regards
Michal

Where is it wrong?

doo.model.<[Přidružení k dokumentu (pav_PridruzDokument)]>.value =  {
dokumenty_Popis: null, 
originalId: doo.model.<[Přidružení k dokumentu (pav_PridruzDokument)]>.value.dokumenty_Popis, 
_$$changed: true 
}

Thanks for help.

Well I have schema X, where is field linked to another schema Y.
And for some type at schema X I need to clear some fields before save

if (doo.model.<[Typ (pav_Typ)]>.value ==='Bilance') {
  	doo.model.<[Příjem na (pav_PrijemNa)]>.value = null;
  	doo.model.<[Přidružení k dokumentu (pav_PridruzDokument)]>.value = {...};
}

where doo.model.<[Přidružení k dokumentu (pav_PridruzDokument)]>.value is field with link to schema Y.

1 Like

I guess you did not setup the id property. Check the example again, please:

if (doo.model.xxx.value.id) {
  doo.model.xxx.value = { id: null, originalId: doo.model.xxx.value.id, _$$changed: true }
}

Maybe I am blind, but I guess id is set as dokumenty_Popis.

doo.model.<[Přidružení k dokumentu (pav_PridruzDokument)]>.value =  {
dokumenty_Popis: null, 
originalId: doo.model.<[Přidružení k dokumentu (pav_PridruzDokument)]>.value.dokumenty_Popis, 
_$changed: true 
}

I am afraid the system is looking for id property. It is necessary to point to the record by id.
In the next version, we publish setValue method for lookup. Currently, we are testing that.
Maybe - if you can wait few days, it could be easier for you.
I will ask for detail the dev team.
Regards
Michal