setLocation on Tableview at runtime

Hi All

I am having problems setting fields on a table view to be different for different customer formats.
I have code that needs to set certain fields to visible \invisible and set location to change column order and then set the tab sequence
As the user scrolls through th navigator, the form must update coulns depending on the format indicator.

The code returns inconsistent results so am in urgent need of a solution.
Has anyone done code for a similar situation that works?

There is a warning on the setLocation tooltip that says if anchored should use solutionModel
Tried that as per other posts on the forum that should work, but no.
Using solutionModel gives a error “Stale form(s) detected, form(s) were altered by the solution model without destroying them first”
test code :
// Rearrange columns order per format using solution model
var jsForm = solutionModel.getForm(“lst_orderLines”);
var jsField = jsForm.getField(“fld_ordhedid”);
jsField.x = 40;
jsField = jsForm.getField(“fld_orpopid”);
jsField.x = 45;
jsField = jsForm.getField(“fld_ordjobcode”);
jsField.x = 50;
controller.recreateUI();

the code that gives inconsistent results is as follows
function onEventFormat() {
// Select based on format options

application.output(gceveid_to_fixeventz.eveformat)

//Step 0 - check if format different to last invoice and only change if different

if(scopes.eve.gEveFormat == gceveid_to_fixeventz.eveformat){
// nothing to do
return
}
scopes.eve.gEveFormat = gceveid_to_fixeventz.eveformat

// Step 1 - unselect all nonstandard fields

elements.fld_ordjobcode.visible = false
elements.fld_ordjobname.visible = false
elements.fld_orddetail.visible = false
elements.fld_ordyes1.visible = false
elements.fld_ordyes2.visible = false
elements.fld_ordyes3.visible = false

// Step 2 - enable formats 0,1,2

// Format 0 - Standard ( pomona with inventory )
if(gceveid_to_fixeventz.eveformat < 1 ) {

//Set columns to view
elements.fld_ordjobcode.visible = false
elements.fld_ordjobname.visible = false
elements.fld_ordtxt2.visible = false
elements.ordstkqty.visible = true
elements.ordqtyerror.visible = true
elements.fld_ordbuyqty.visible = true
elements.fld_ordmnfqty.visible = true
elements.fld_ordpicqty.visible = true
elements.fld_ordcxdqty.visible = true
elements.fld_ordpopid.visible = false
elements.ordselcode.visible = true

//Set column order
elements.prdIcon.setLocation(1,1)
elements.fld_ordstart.setLocation(1,2)
// elements.fld_ordpopid.setLocation(1,4)
// elements.fld_ordjobcode.setLocation(1,6)
elements.fld_ordprdid.setLocation(1,8)
elements.fld_ordprdname.setLocation(1,10)
elements.fld_orddetail.setLocation(1,14)
elements.ordselcode.setLocation(1,15)
elements.fld_ordordqty.setLocation(1,16)
elements.fld_ordordprice.setLocation(1,18)
elements.fld_ordorddisc.setLocation(1,20)
elements.ordordexcl.setLocation(1,22)
elements.fld_ordtaxcode.setLocation(1,23)
elements.fld_ordlocation.setLocation(1,24)
elements.ordstkqty.setLocation(1,25)
elements.fld_ordbuyqty.setLocation(1,32)
elements.fld_ordmnfqty.setLocation(1,33)
elements.fld_ordpicqty.setLocation(1,34)
elements.fld_ordcxdqty.setLocation(1,35)
elements.ordqtyerror.setLocation(1,36)
// elements.ordordincl.setLocation(1,37)
//elements.fld_ordtxt2.setLocation(1,41)
elements.fld_ordhedid.setLocation(1,42)
elements.fld_tmpYNField.setLocation(1,43)

//Set tab Sequence
controller.setTabSequence([
elements.prdIcon,
elements.fld_ordstart,
elements.fld_ordprdid,
elements.fld_ordprdname,
elements.fld_orddetail,
elements.ordselcode,
elements.fld_ordordqty,
elements.fld_ordordprice,
elements.fld_ordorddisc,
elements.ordordexcl,
elements.fld_ordtaxcode,
elements.fld_ordlocation,
elements.ordstkqty,
elements.fld_ordbuyqty,
elements.fld_ordmnfqty,
elements.fld_ordpicqty,
elements.fld_ordcxdqty,
elements.ordqtyerror,
elements.fld_ordhedid,
elements.fld_tmpYNField])

//Set field format patterns
elements.fld_ordordprice.format = “#,###.0000”

}

// Format 1 - Jobs ( Oceania)
if(gceveid_to_fixeventz.eveformat == 1 ) {
elements.fld_ordjobcode.visible = true
elements.fld_ordjobname.visible = true
scopes.globals.sqlJobCodes(ordeveid)
}

// Format 2 - NSLC Custom need add fields … Sc / Type / employee / Cad filename
if(gceveid_to_fixeventz.eveformat == 2 ) {

elements.fld_ordyes1.titleText = “CS”
elements.fld_ordyes2.titleText = “Prn”
elements.fld_ordyes3.titleText = “Y3”

scopes.globals.sqlJobCodes(ordeveid)

elements.fld_ordprdname.readOnly = true

elements.ordstkqty.visible = false
elements.ordqtyerror.visible = false
elements.fld_ordbuyqty.visible = false
elements.fld_ordpicqty.visible = false
elements.fld_ordcxdqty.visible = false
elements.fld_ordyes3.visible = false
elements.ordselcode.visible = false
elements.fld_ordlocation.visible = false
elements.fld_ordmnfqty.visible = false

elements.fld_ordpopid.visible = true
//elements.fld_ordmnfqty.visible = true
elements.fld_ordjobcode.visible = true
elements.fld_orddetail.visible = true
elements.ordordincl.visible = true
elements.fld_ordyes1.visible = true
elements.fld_ordyes2.visible = true
elements.fld_ordtxt2.visible = true //‘CAD File Name’

elements.prdIcon.setLocation(1,1)
elements.fld_ordstart.setLocation(1,2)
elements.fld_ordjobcode.setLocation(2,40)
elements.fld_ordpopid.setLocation(2,40)
elements.fld_ordprdid.setLocation(1,118)
elements.fld_ordprdname.setLocation(1,110)
elements.fld_orddetail.setLocation(1,114)
elements.fld_ordordqty.setLocation(1,116)
elements.fld_ordordprice.setLocation(1,118)
elements.fld_ordorddisc.setLocation(1,120)
elements.ordordexcl.setLocation(1,122)
elements.ordordincl.setLocation(1,124)
elements.fld_ordtxt2.setLocation(1,126)
elements.fld_ordyes1.setLocation(1,128)
elements.fld_ordyes2.setLocation(1,129)
elements.fld_tmpYNField.setLocation(1,130)
elements.fld_ordhedid.setLocation(1,131)
elements.fld_ordtaxcode.setLocation(1,132)

//Move invisible fields out the way

elements.fld_ordyes3.setLocation(1,39)
elements.ordstkqty.setLocation(1,40)
elements.ordqtyerror.setLocation(1,341)
elements.fld_ordbuyqty.setLocation(1,42)
elements.fld_ordpicqty.setLocation(1,43)
elements.fld_ordcxdqty.setLocation(1,44)
elements.fld_ordyes3.setLocation(1,45)
elements.ordselcode.setLocation(1,46)
elements.fld_ordlocation.setLocation(1,47)
elements.fld_ordmnfqty.setLocation(1,48)
elements.fld_ordjobcode.setLocation(1,50)
elements.fld_ordjobname.setLocation(1,51)
elements.fld_ordmnfqty.setLocation(1,52)

controller.setTabSequence([
elements.prdIcon,
elements.fld_ordstart,
elements.fld_ordjobcode,
elements.fld_ordpopid,
elements.fld_ordprdid,
elements.fld_ordprdname,
elements.fld_orddetail,
elements.fld_ordordqty,
elements.fld_ordordprice,
elements.fld_ordorddisc,
elements.ordordexcl,
elements.ordordincl,
elements.fld_ordtxt2,
elements.fld_ordyes1,
elements.fld_ordyes2,
elements.fld_tmpYNField,
elements.fld_ordhedid]);

elements.fld_ordordprice.format = “#,###.00”

}

}
Any advice appreciated.
Mark