xTuple.com xTupleU Blog & News Customer Support

Who do I trap the adresscluster postalcode change?

I need to trap changes to the postalcode in the address cluster.

I looked at the documentation and code and could not figure how to specifically trap the postalcode change.

I tried the following plus several variation but I was not successful. The code below call the function checkZip()

about 5 times as the successive fields get loaded.

From the doc: https://www.xtuple.org/sites/default/files/dev/latest/html/class_address_cluster.html#a5540070c63cbc4e9569027ad23ee3ed4

I see that the addressChange  accepts several parameters but I am not sure what.

I am using this on shipTo screen for customers.

Help Please!

void  addressChanged (QStringQStringQStringQStringQStringQStringQString)



//QMessageBox.information(mywindow,mywindow.windowTitle, "we are here: " );


var _address = mywindow.findChild("_address"); //empty until address field are loaded 


//Q_INVOKABLE virtual QString postalCode() const { return _postalcode->text(); }


_address.addressChanged.connect(checkZip); //seems to fire every time a field is changed


function checkZip()


var tmp =_address.postalCode();


QMessageBox.information(mywindow,mywindow.windowTitle, "postal code: " + tmp );



But you can capture if it is different than the old one and do nothing if it is:

   var _address = mywindow.findChild("_address");

var origzip = _address.postalCode();


function checkZip(addr1, addr2, addr3, city, state, zip, country) {

  if (zip != origzip && zip.length >=5) { //assuming 5

    QMessageBox.information(mywindow,mywindow.windowTitle, "postal code: " + _address.postalCode());



_address["addressChanged(QString, QString, QString, QString, QString, QString, QString)"].connect(checkZip);   


This will capture the zip from the signal that fires, but you will have to deal with ignoring it if it is less than 5 digits or whatever



Thanks David!

That helps a lot.