Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Is Object or Lookup field empty

Questions related to using nuBuilder Forte.
Post Reply
Uzlander
Posts: 60
Joined: Sat Jul 08, 2023 10:21 am
Has thanked: 9 times
Been thanked: 3 times

Is Object or Lookup field empty

Unread post 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) ?
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: Is Object or Lookup field empty

Unread post 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);
    }

}
Uzlander
Posts: 60
Joined: Sat Jul 08, 2023 10:21 am
Has thanked: 9 times
Been thanked: 3 times

Re: Is Object or Lookup field empty

Unread post by Uzlander »

Yeah, it works!
The idea being to generate some custom human readable id based on few other entities/params. Thank you sir
Post Reply