Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

nuuserhome Custom Code Removed on Upgrade

Questions related to installing, updating, setting up and configuring
Post Reply
pmjd
Posts: 132
Joined: Fri Mar 12, 2021 10:38 am
nuBuilder Version: 4.5

nuuserhome Custom Code Removed on Upgrade

Unread post by pmjd »

Hello,

Not sure if this is a bug or by design but each time I update to newer version of nuBuilder 4.5 the JS code I have in the nuuserhome Custom Code area is always removed and replaced by the default code.

Code: Select all

function openNuObject() {

    $('#nuMessageDiv').remove();
    nuPopup('nuobject', '-1', window.nuFORM.getCurrent().form_id, '', 0);

}

if (nuSERVERRESPONSE.objects.length === 0 && window.global_access) {

    var headings = '<h2>' + nuTranslate('Information') + '<h2>';
	var message = nuTranslate('Currently there are no objects on this Form') + '. <a href="javascript:openNuObject();">'+ nuTranslate('Start adding some') + '</a>.';
	nuMessage([headings, message]);

}
Is there any way to stop this? or is it just one to be aware of when upgrading and copy it out to paste back in to the new version?

Cheers,
Paul
kev1n
nuBuilder Team
Posts: 3826
Joined: Sun Oct 14, 2018 6:43 pm
nuBuilder Version: 4.5
Has thanked: 2 times
Been thanked: 9 times
Contact:

Re: nuuserhome Custom Code Removed on Upgrade

Unread post by kev1n »

All changes to nuBuilder's core forms and objects, in other words all records with a nu- primary key prefix are overwritten when updating.
Move your code to Setup->Header instead.

Example header:

Code: Select all

function nuHeaderTest() {
    console.log('Functions placed here are available anywhere in nuBuilder Forte.');
}

// nuOnLoad() will be run after each Browse and Edit Form loads. 

function nuOnLoad() {

    if (nuFormType() == 'edit') {
        // Edit Form loaded
		
		if (nuCurrentProperties().form_id == 'nuuserhome') {
		
			// YOUR CODE HERE... 
		}
    
	
    } else
    if (nuFormType() == 'browse') {
        // Browse Form loaded
    }

}

// </script>

<!-- Define your own styles, override styles from nubuilder4.css -->

<style> 

 /*.nuActionButton {background-color:#0073aa;} */



</style>


<script>	

pmjd
Posts: 132
Joined: Fri Mar 12, 2021 10:38 am
nuBuilder Version: 4.5

Re: nuuserhome Custom Code Removed on Upgrade

Unread post by pmjd »

Thanks, good to know.

I thought anything in the header would be applied globally, so only used it for a few things.
kev1n
nuBuilder Team
Posts: 3826
Joined: Sun Oct 14, 2018 6:43 pm
nuBuilder Version: 4.5
Has thanked: 2 times
Been thanked: 9 times
Contact:

Re: nuuserhome Custom Code Removed on Upgrade

Unread post by kev1n »

The functions in the header are run everytime a form is loaded. But you can still decide for which form the should run.
Post Reply