HI I try to use a switch case in microsoft dynamics nav.
I have this:
CASE Betalingswijze OF
'kontant':
TemplateHeader.Code :='KNT-KLANT';
'rekening':
TemplateHeader.Code :='REK-KLANT';
'automatische incasso':
TemplateHeader.Code :='BIN-INC-KL';
ELSE
TemplateHeader.Code :='KONTANT';
END;
and this:
RecRef.GETTABLE("<Customer>");
//connect the payment method to the TemplateHeader and update the record:
//rekening
TemplateHeader.SETFILTER(TableID, FORMAT(18));
IF Betalingswijze := 'kontant' THEN
TemplateHeader.SETFILTER(TemplateHeader.Code,'REK-KLANT' );
UpdateRecordTemplate.UpdateRecord(TemplateHeader, RecRef);
//kontant
TemplateHeader.SETFILTER(TableID, FORMAT(18));
TemplateHeader.SETFILTER(TemplateHeader.Code,'KNT-KLANT' );
UpdateRecordTemplate.UpdateRecord(TemplateHeader, RecRef);
//automatische incasso
TemplateHeader.SETFILTER(TableID, FORMAT(18));
TemplateHeader.SETRANGE(TemplateHeader.Code,'BIN-INC-KL' );
UpdateRecordTemplate.UpdateRecord(TemplateHeader, RecRef);
But now all the tree options are selected an not one.
So how to manage that only one selection will be selected?
Thank you
I have solved like this. I'v forgot to say that it is reading from a xml file.
CASE Betalingswijze OF
'kontant':
TemplateHeader.Code :='KNT-KLANT';
'rekening':
TemplateHeader.Code :='REK-KLANT';
'automatische incasso':
TemplateHeader.Code :='BIN-INC-KL';
ELSE
TemplateHeader.Code :='KONTANT';
END;
and in Company information, like this:
RecRef.GETTABLE("<Customer>");
//connect the payment method to the TemplateHeader and update the record:
//rekening
TemplateHeader.SETFILTER(TableID, FORMAT(18));
IF TemplateHeader.Code = 'KNT-KLANT' THEN
TemplateHeader.SETFILTER(TemplateHeader.Code,'REK-KLANT');
//kontant
IF TemplateHeader.Code = 'REK-KLANT' THEN
TemplateHeader.SETFILTER(TemplateHeader.Code,'KNT-KLANT' );
//automatische incasso
IF TemplateHeader.Code = 'BIN-INC-KL' THEN
TemplateHeader.SETFILTER(TemplateHeader.Code,'BIN-INC-KL' );
UpdateRecordTemplate.UpdateRecord(TemplateHeader, RecRef);
this is the right code:
RecRef.GETTABLE("<Customer>");
TemplateHeader.RESET;
TemplateHeader.SETFILTER(TableID, FORMAT(18));
CASE Betalingswijze OF
'kontant' : TemplateHeader.setrange(Code,'KNT-KLANT');
'rekening' : TemplateHeader.setrange(Code,'REK-KLANT');
'automatische incasso': TemplateHeader.setrange(Code,'BIN-INC-KL');
ELSE TemplateHeader.setrange(Code,'KONTANT');
END;
IF TemplateHeader.FINDFIRST THEN
UpdateRecordTemplate.UpdateRecord(TemplateHeader, RecRef);
You've made a few mistakes in your code:
I hope it helps.
Cheers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.