oups!
Hello,
I was so distressed with the idea of having an error in my code that i didn’t read well all the post 
1/ So the idea is that I have a SelectItem in a form. According to some user interaction, I have to change the value and valueMap; and, by consequence, the ‘PickList’ data must be refetched.
(the real case is that the values in the ‘SelectItem’ depend on the value of another item and i need to modify the ‘SelectItem’ everytime the ‘source’ item is changed)
I have several fields in my ‘PickList’ (like the ‘List - Related Records’ feature explorer’s example)
The purpose of my post was to empty the cache so that the ‘PickList’ data is refetched when the user opens the ‘PickList’ again. And not get it everytime which is what happens when using ‘fetchData’.
I can’t set autoFetchData to true since I don’t want to get the PickList data unless the user opens the list.
So is there a way to empty the data of the ‘PickList’ without calling ‘fetchData’ ? and therefore having the data fetched the next time the user opens the list ?
I tried setting the 'SelectItem’s property ‘cachePickListResults’ to false but it doesn’t change anything.
Thank you for any insight on what could be done in this case.
Here is the example :
A Form with a selectItem, and a button to test the change in values of the SelectItem
isc.setAutoDraw(true);
var index = 0;
function getDataUrl () {
if (index == 0)
return "./data/projets1.xml";
else
return "./data/projets2.xml";
}
function setNewValues () {
var newValue = 8;
var newValueMap = { "9": "construire", "8": "redresser"};
var item = form.getItem ("1456763482");
//alert (item.
item.setValueMap (newValueMap);
item.setValue (newValue);
index++;
item.optionDataSource.dataURL = getDataUrl ();
item.fetchData (
// function (item, dsResponse) {
// item.setValueMap (newValueMap);
// }
);
// CLEAR THE PICK LIST CACHE INSTEAD OF CALLING FETCH DATA
}
isc.DynamicForm.create({
ID: "form",
numCols: 4*2,
fields: [
{name: "1456763482", title: "Projet", type: "select", required: true, startRow: false, endRow: false,pickListWidth: 400
,addUnknownValues: false
,setValue: function (newValue) {
this.Super ("setValue", arguments);
}
,setValueMap: function (newValue) {
this.Super ("setValueMap", arguments);
this.fetchData ();
}
,autoFetchDisplayMap: false
,autoFetchData: false
,valueField: "key", displayField: "name"
,optionDataSource: isc.DataSource.create({
showPrompt: false,
dataFormat: "xml",
dataURL: getDataUrl (),
recordXPath: "//value",
fields: {
key: {valueXPath:"@key", title:"key", primaryKey:true, name:"key"},
name: {valueXPath:"@label", title:"name", name:"name"}
, X31333134353430333034: {valueXPath:"X31333134353430333034", title:"Projet", name:"X31333134353430333034"}
, X32303133313935323831: {valueXPath:"X32303133313935323831", title:"Chantier", name:"X32303133313935323831"}
}
})
,pickListFields: [
{name: "X31333134353430333034"}
,
{name: "X32303133313935323831"}
]
,defaultValue: "1"
, valueMap: {
"1" : "Achat"
,"10" : "Achat Spécifique"
,"12" : "I.T. Spécifique"
,"2" : "Logistique"
,"13" : "Logistique Spécifique"
,"6" : "Relation Client"
,"7" : "Ressources Humaines"
,"5" : "Structure et frais généraux"
,"3" : "Vente et marketing"
,"11" : "Vente et marketing Spécifique"
}
}
]
});
isc.Button.create ({
top: 300, title: "test",
click: function () {
setNewValues ();
}
})
projets1.xml
<values uuid="cb50516e"><value key="13" label="Logistique Spécifique"><X31333134353430333034 name="projet">Logistique Spécifique</X31333134353430333034><X32303133313935323831 name="chantier">économie</X32303133313935323831></value><value key="12" label="I.T. Spécifique"><X31333134353430333034 name="projet">I.T. Spécifique</X31333134353430333034><X32303133313935323831 name="chantier">économie</X32303133313935323831></value><value key="11" label="Vente et marketing Spécifique"><X31333134353430333034 name="projet">Vente et marketing Spécifique</X31333134353430333034><X32303133313935323831 name="chantier">économie</X32303133313935323831></value><value key="10" label="Achat Spécifique"><X31333134353430333034 name="projet">Achat Spécifique</X31333134353430333034><X32303133313935323831 name="chantier">économie</X32303133313935323831></value><value key="7" label="Ressources Humaines"><X31333134353430333034 name="projet">Ressources Humaines</X31333134353430333034><X32303133313935323831 name="chantier">économie</X32303133313935323831></value><value key="6" label="Relation Client"><X31333134353430333034 name="projet">Relation Client</X31333134353430333034><X32303133313935323831 name="chantier">économie</X32303133313935323831></value><value key="5" label="Structure et frais généraux"><X31333134353430333034 name="projet">Structure et frais généraux</X31333134353430333034><X32303133313935323831 name="chantier">économie</X32303133313935323831></value><value key="3" label="Vente et marketing"><X31333134353430333034 name="projet">Vente et marketing</X31333134353430333034><X32303133313935323831 name="chantier">économie</X32303133313935323831></value><value key="2" label="Logistique"><X31333134353430333034 name="projet">Logistique</X31333134353430333034><X32303133313935323831 name="chantier">économie</X32303133313935323831></value><value key="1" label="Achat"><X31333134353430333034 name="projet">Achat</X31333134353430333034><X32303133313935323831 name="chantier">économie</X32303133313935323831></value></values>
projets2.xml
<values uuid="6d4029e1"><value key="9" label="construire"><X31333134353430333034 name="projet">construire</X31333134353430333034><X32303133313935323831 name="chantier">redresser et construire</X32303133313935323831></value><value key="8" label="redresser"><X31333134353430333034 name="projet">redresser</X31333134353430333034><X32303133313935323831 name="chantier">redresser et construire</X32303133313935323831></value></values>
2/ On the same point, while trying with ‘fetchData’, it’s working OK, but I have a problem.
On click of the button, I get an error"
this.formItem is undefined
,isc.A.$315=function(_1,_2,_3,_4,_5){if(…formItem.formatPickListValue(_1,_6,_2)}
"
which I managed to track to the PickListMenu class in ‘ISC_Forms.js’
This happens when I open the PickList of the Item before changing the values (ie clicking the button).
If I do not open the picklist before, I don’t get the error
If I don’t set the valueMap, I don’t have the error.
so I tried setting the ‘valueMap’ : before or after the fetch and even in the fetchData callback but I have the error everytime.
I need to set the ValueMap becuase I need to show the correct value of the item even when the PickList is not opened and its data fetched.