Page 1 of 1

Is Object or Lookup field empty

Posted: Wed Aug 13, 2025 8:33 am
by Uzlander
Hi dev folks!
I've been struggling with checking if a Lookup type field populated (or empty) & depending on that populate another (text) filed.
Must admit I'm not particularly good at js (even jquery for that case), but i failed to do so, somehow my lookup field always showing filled (on screenshot top).
Here's my attempt(below)

Code: Select all

let oby = nuGetObjectId('obyekt');

let b = nuGetValue('blok') || "UB";
let e = nuGetValue('pod') || "UE"; 
let f = nuGetValue('etaj') || "UF"; 
let n = nuGetValue('nom') || "UN";

if (nuIsNewRecord()) { 
  if (oby !== null) nuSetValue('hid', 'b'+ b +'e'+ e +'f'+ f +'n'+ n);
}

i wonder if there's a built in method to make such checking (for objects/lookups) ?

Re: Is Object or Lookup field empty

Posted: Wed Aug 13, 2025 8:38 am
by kev1n
Hi,

Like this?

Code: Select all

if (nuIsNewRecord()) {

    if (nuGetValue('obyekt') !== '') {

        let b = nuGetValue('blok') || "UB";
        let e = nuGetValue('pod') || "UE";
        let f = nuGetValue('etaj') || "UF";
        let n = nuGetValue('nom') || "UN";

        nuSetValue('hid', 'b' + b + 'e' + e + 'f' + f + 'n' + n);
    }

}

Re: Is Object or Lookup field empty

Posted: Wed Aug 13, 2025 3:58 pm
by Uzlander
Yeah, it works!
The idea being to generate some custom human readable id based on few other entities/params. Thank you sir