I'm trying to disable sublist field, in order to fillment of another sublist field. However, it seems to me it's not working. I used lineInit(cuz it looks like what i need at the moment).
function lineInit(context) {
var cr = context.currentRecord;
var selectedLine = cr.getCurrentSublistIndex({sublistId: "item"});
var iskontoOran = cr.getCurrentSublistValue({sublistId: "item", fieldId : "custcol_delta_iskonto_oran"});
if (iskontoOran != "0.00"){
cr.getCurrentSublistValue({sublistId : "item", fieldId: "custcol_delta_iskonto_tutar", line: 0
}).isDisabled = true;
}
else {
cr.getCurrentSublistValue({sublistId : "item", fieldId: "custcol_delta_iskonto_tutar", line: 0
}).isDisabled = false;
}
function fieldChanged(context) {
var myRec = context.currentRecord;
var itemCount = myRec.getLineCount("item");
var anlıkLine = myRec.getCurrentSublistIndex({ sublistId: "item" });
var sublistName = myRec.getSublist({sublistId: "item"});
var oranColumn = sublistName.getColumn({ fieldId: "custcol_delta_iskonto_oran" });
var tutarColumn = sublistName.getColumn({ fieldId: "custcol_delta_iskonto_tutar" });
var currOran = myRec.getCurrentSublistValue({ sublistId: "item", fieldId: "custcol_delta_iskonto_oran" });
var currTutar = myRec.getCurrentSublistValue({ sublistId: "item", fieldId: "custcol_delta_iskonto_tutar" });
if (currTutar) {
myRec.setCurrentSublistValue({
sublistId: "item",
fieldId: "custcol_delta_iskonto_oran",
value: "",
ignoreFieldChange: true
});
oranColumn.isDisabled = true;
} else {
oranColumn.isDisabled = false;
}
if (currOran) {
myRec.setCurrentSublistValue({
sublistId: "item",
fieldId: "custcol_delta_iskonto_tutar",
value: "",
ignoreFieldChange: true
});
tutarColumn.isDisabled = true;
} else {
tutarColumn.isDisabled = false;
}
}
function lineInit(context) {
var myRec = context.currentRecord;
var itemCount = myRec.getLineCount("item");
var anlıkLine = myRec.getCurrentSublistIndex({ sublistId: "item" });
var quantity = myRec.getCurrentSublistValue({ sublistId: "item", fieldId: "quantity" });
log.debug({ title: "AnlıkLine, Quantity ve itemCount-LineInit", details: "anlıkLine = " + anlıkLine + ", quantity = " + quantity + ", itemcount = " + itemCount });
for (var j = 0; j < itemCount; j++) {
if (quantity){
var oranField = myRec.getSublistField({ sublistId: "item", fieldId: "custcol_delta_iskonto_oran", line: j });
var tutarField = myRec.getSublistField({ sublistId: "item", fieldId: "custcol_delta_iskonto_tutar", line: j });
var currOran = myRec.getCurrentSublistValue({ sublistId: "item", fieldId: "custcol_delta_iskonto_oran" });
var currTutar = myRec.getCurrentSublistValue({ sublistId: "item", fieldId: "custcol_delta_iskonto_tutar" });
if (currTutar) {
myRec.setCurrentSublistValue({
sublistId: "item",
fieldId: "custcol_delta_iskonto_oran",
value: "",
ignoreFieldChange: true
});
oranField.isDisabled = true;
} else {
oranField.isDisabled = false;
}
if (currOran) {
myRec.setCurrentSublistValue({
sublistId: "item",
fieldId: "custcol_delta_iskonto_tutar",
value: "",
ignoreFieldChange: true
});
tutarField.isDisabled = true;
log.debug({ title: "Tutar Alanı
} else {
tutarField.isDisabled = false;
}
}
}
}
So this is my aproach and it is working fine at the moment. Can it be more nice? Yeah, probably but it does do the job for now :)