Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Is Object or Lookup field empty

Questions related to using nuBuilder Forte.
Post Reply
Uzlander
Posts: 51
Joined: Sat Jul 08, 2023 10:21 am
Has thanked: 7 times
Been thanked: 2 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: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 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: 51
Joined: Sat Jul 08, 2023 10:21 am
Has thanked: 7 times
Been thanked: 2 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