Published on InterSystems Developer Community (https://community.intersystems.com)

Home > changed data in field ignored when saving changes

Question
Marco Blom · Jul 7, 2017

changed data in field ignored when saving changes

HI Community,

I do have a table with quite some names written in Uppercase:

To simply correct this, I have created a button with some code behind it.:

ClientMethod convertToTitle() [ Language = javascript ]
{
    
    var ctrl = zen('Relation');
tVar = ctrl.getValue();
     
tVar = this.StringConvert(tVar)

    zenPage.getComponentById('Relation').setValue(tVar)
}



ClientMethod StringConvert(str) [ Language = javascript ]
{
    ///alert (str)
    str = str.substring(0,1).toLowerCase() + tVar.substring(1).toLowerCase();
    ///alert (str)
    var pieces = str.split(" ");
    for ( var i = 0; i < pieces.length; i++ )
    {
        var j = pieces[i].charAt(0).toUpperCase();
        
        pieces[i] = j + pieces[i].substr(1);
    }
        
    return pieces.join(" ");
} ClientMethod convertToTitle() [ Language = javascript ]
{
    
    var ctrl = zen('Relation');
tVar = ctrl.getValue();
     
tVar = this.StringConvert(tVar)

    zenPage.getComponentById('Relation').setValue(tVar)
}



ClientMethod StringConvert(str) [ Language = javascript ]
{
    ///alert (str)
    str = str.substring(0,1).toLowerCase() + tVar.substring(1).toLowerCase();
    ///alert (str)
    var pieces = str.split(" ");
    for ( var i = 0; i < pieces.length; i++ )
    {
        var j = pieces[i].charAt(0).toUpperCase();
        
        pieces[i] = j + pieces[i].substr(1);
    }
        
    return pieces.join(" ");
}

At first place it seems to worksmiley: using the correct button results in:

 

 

However when I do save (by the button or code), then the data gets replaced with the original Uppercase data.crying

 

Does somebody have a clue why this behavior appears?

Thanks in advance!

By the way: some server side alternative solution sample(s) are more than welcome!

#Caché #JavaScript

Source URL:https://community.intersystems.com/post/changed-data-field-ignored-when-saving-changes