Search This Blog

Thursday, September 8, 2011

Change Enum Values using X++

 static void krishh_enumValueChange(Args _args)
     {
         DictTable dictTable;
    
         void makeConversion(FieldId _fieldId, Integer _valueFrom, Integer _valueTo)
         {
             Common dictCommon;
             ;
    
             dictCommon = dictTable.makeRecord();
    
             while select dictCommon
                 where dictCommon.(_fieldId) == _valueFrom
             {
                 if(dictCommon.RecId)
                 {
                     ttsbegin;
                     dictCommon.selectForUpdate(true);
                     dictCommon.(_fieldId) = _valueTo;
                     dictCommon.update();
                     ttscommit;
                 }
             }
         }
         ;
    
         // 1. Table - LedgerJournalTable
         dictTable = new DictTable(tablenum(LedgerJournalTable));
         makeConversion(fieldnum(LedgerJournalTable, JournalType), 3, 4);
         makeConversion(fieldnum(LedgerJournalTable, JournalType), 4, 3);
         makeConversion(fieldnum(LedgerJournalTable, JournalType), 5, 6);
     }

No comments:

Post a Comment

Thanks for visiting my blog,
I will reply for your comment within 48 hours.

Thanks,
krishna.