Page 1 of 1

nuuserhome Custom Code Removed on Upgrade

Posted: Fri Jul 23, 2021 6:08 pm
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

Re: nuuserhome Custom Code Removed on Upgrade

Posted: Fri Jul 23, 2021 7:39 pm
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>	


Re: nuuserhome Custom Code Removed on Upgrade

Posted: Sun Jul 25, 2021 4:54 pm
by pmjd
Thanks, good to know.

I thought anything in the header would be applied globally, so only used it for a few things.

Re: nuuserhome Custom Code Removed on Upgrade

Posted: Sun Jul 25, 2021 5:57 pm
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.