Skip to content

Instantly share code, notes, and snippets.

@mindspank
Last active September 26, 2015 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindspank/cbd243cdf4ec15f365eb to your computer and use it in GitHub Desktop.
Save mindspank/cbd243cdf4ec15f365eb to your computer and use it in GitHub Desktop.
Set listbox in alternate state
/**
* Add a new alternate states to a app.
* Change a listbox to use this new alternate state.
*/
var qsocks = require('qsocks')
qsocks.Connect({appname: 'Sales Discovery.qvf'})
.then(function(global) {
return global.openDoc('Sales Discovery.qvf')
})
.then(function(app) {
//Add a new alternate state to the app.
app.addAlternateState('MyNewState').then(function() {
//Fetch a generic object, in this case a listbox.
return app.getObject('QEECN').then(function(object) {
//Set the objects qListObjectDef to use our new alternate state
return object.applyPatches([{
"qPath": '/qListObjectDef/qStateName',
"qOp": 'add',
"qValue": '"MyNewState"'
}])
})
})
.then(function() {
//Persist changes
app.doSave();
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment