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.

Uncaught TypeError: Cannot read properties of null (reading 'style') when Cloning a record Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
Paul
Posts: 175
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 32 times
Been thanked: 5 times

Uncaught TypeError: Cannot read properties of null (reading 'style') when Cloning a record

Post by Paul »

When I am in the Edit form and viewing a record:
1. I click "Clone"
2. Click "Save"
OBSERVE:

Code: Select all

Uncaught TypeError: Cannot read properties of null (reading 'style')
    at nuSetBrowseColumns (nuform.js:4960:12)
    at nuDragTitleEvents (nucommon.js:2150:2)
    at nuBuildForm (nuform.js:140:1)
    at Object.successCallback (nuajax.js:193:4)
    at c (jquery-3.7.1.min.js:2:25304)
    at Object.fireWith [as resolveWith] (jquery-3.7.1.min.js:2:26053)
    at l (jquery-3.7.1.min.js:2:77782)
    at XMLHttpRequest.<anonymous> (jquery-3.7.1.min.js:2:80265)


Line 4960 of nuform.js:
nucell00.style.zIndex = '2';
Contents of Edit js:

Code: Select all

if (nuIsNewRecord()) {
        // Set the value of the select object
        nuSetValue('pk_finalDoughIngred1','sourdough starter');
	nuSetValue('pk_finalDoughIngred2','water');
	nuSetValue('pk_finalDoughIngred3','salt');
        
    }
I recently added a Display object that displays the current record ID in the Edit form:
The object ID is: 'myrecordnumber'
The display SQL is:

Code: Select all

select table1_id from table1 where table1_id = '#RECORD_ID#';
I can create NEW records without any problems.
kev1n
nuBuilder Team
Posts: 4601
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 77 times
Been thanked: 547 times
Contact:

Re: Uncaught TypeError: Cannot read properties of null (reading 'style') when Cloning a record

Post by kev1n »

Can you share a screenshot of the object properties and the actual SQL used?
Paul
Posts: 175
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 32 times
Been thanked: 5 times

Re: Uncaught TypeError: Cannot read properties of null (reading 'style') when Cloning a record

Post by Paul »

myrecordnumber.PNG
myrecordnumber-sql.PNG
You do not have the required permissions to view the files attached to this post.
Paul
Posts: 175
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 32 times
Been thanked: 5 times

Re: Uncaught TypeError: Cannot read properties of null (reading 'style') when Cloning a record

Post by Paul »

It displays with no problems.
recordnum.PNG
You do not have the required permissions to view the files attached to this post.
Paul
Posts: 175
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 32 times
Been thanked: 5 times

Re: Uncaught TypeError: Cannot read properties of null (reading 'style') when Cloning a record

Post by Paul »

Console info: (I am not sure how to interpret this. Help?)

Code: Select all

Explanation

Understanding the problem
The error Uncaught TypeError: Cannot read properties of null (reading 'style') means that you are trying to access the style property of a variable that is currently null. In this specific case, the error occurs on line 4960 of nuform.js within the nuSetBrowseColumns function. The code on that line is trying to access the style property of an element that could not be found.

How to verify
You can set a breakpoint on line 4960 in nuform.js in the Sources panel of DevTools. When the code execution pauses at this line, hover over the variable that you are trying to access the style property from. Its value will likely be null. You can also check the call stack in the right-hand sidebar to see how the nuSetBrowseColumns function was called, which might provide clues about why the element was not found.

Suggested fix
The most common reason for this error is trying to access a DOM element before it has been loaded on the page, or if the selector used to find the element is incorrect. Ensure that the element you are trying to access exists in the DOM when the nuSetBrowseColumns function is executed. You can wrap the code that accesses the element within a DOM ready event listener or check if the element exists before trying to access its properties.
Paul
Posts: 175
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 32 times
Been thanked: 5 times

Re: Uncaught TypeError: Cannot read properties of null (reading 'style') when Cloning a record

Post by Paul »

I found the problem - it was incorrect integer data in the database for two fields. I changed the datatype for each of them and then deleted the bad data - that fixed it.
Post Reply