ajax event on new record

I have a problem. I would like to highlight a field (using ajax event on field codiceazienda_onchange) only if the new record. I tried with:

if(empty({codice})){ //{codice} is primary key
{cartelladocumenti}={codiceazienda};
}

I also tried it with:

if(sc_btn_new){
{cartelladocumenti}={codiceazienda};
}

I do not work.

What do you understand with highlight?

I mean: I would like to assign a value.
I’m sorry for the translation, but I use google traslator.

Hi kkkpe,

You could use the event onLoadRecord of your form with something like

If (empty({primary_key_field}))
{
{fieldname} = <value>;
}

You’re doing something similar:

if(empty({codice})){ //{codice} is primary key
{cartelladocumenti}={codiceazienda};
}

but you’re doing it in a javascript event and using another field. Are you sure there’s a value in codiceazienda? Could you try putting the code in the onLoadRecord event?

I saw you’re using google translator. What’s your native language? Italian?

Sei sicuro che c’? un valore nel codice azienda? Potresti provare a mettere il codice in onLoadRecord?
Ciao