web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Change the description of movement journal item

(0) ShareShare
ReportReport
Posted on by

I have added a new movement journal and I want to change the Description

which is stored on table Invent JournalTable...

How am i going to change the value of "Description" through code

here is my code

******************************

Public void uploadFromCSV() //returns container
{
int row = 1;//, failedCtr = 0;
//boolean blnFail = false;

//Tables
InventJournalTable journalTable;
InventJournalTrans journalTrans;
//Classes
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
//InventJournalStatic journalStatic;
InventDim inventDim, itemInventDim;
InventTable InventTable;
MainAccountNum _account;
DimensionDynamicAccount ledgerDim;
DimensionDynamicAccount defaultDim;
ItemId localItemId;
//SIStype sisType;
//SISType sisType;

Counter failedCtr = 0;

JournalCheckPost journalCheckPost;
InventJournalTable inventJournalTable;
;

[filepath, fileNameOnly, type] = fileNameSplit(fileName);
importFile = new AsciiIo(fileName,'R');
importFile.inFieldDelimiter(#Delimiter);

record = importFile.read();

if(!(importFile) || (importFile.status() != IO_Status::Ok))
{
warning('Error in opening log file.');
throw(Exception::Error);
}

ttsBegin;
journalTableData = journalTableData::newTable(journalTable);

journalTransData = journalTableData.journalStatic().newJournalTransData(
journalTrans, journalTableData);

journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalType = InventJournalType::Movement;

//journalTable.Description = "TEST DESCRIPTION"

journalTable.journalNameId = journalNameId;
journalTable.initFromInventJournalName(InventJournalName::find(
journalTable.JournalNameId));


while (importFile.Status() == IO_Status::Ok)
{
try
{
record = importFile.Read();
if (record)
{
row++;
localItemId = conPeek(record, column2);
//sisType = conPeek(record, column17);
//sisType = "SISAR"
// sisType = str2enum(SISType,"1");
//sisType = str2enum(SISType,"SISAR");

//sisType = conPeek(record, column17);
info(conPeek(record,column17));
InventTable = InventTable::find(localItemId);
if (InventTable)
{
account = conPeek(record, column14);
finDim1 = conPeek(record, column15);
finDim2 = conPeek(record, column16);

finDim3 = conPeek(record, column18);
finDim4 = conPeek(record, column19);
finDim5 = conPeek(record, column20);

//ledgerDim = this.getLedgerAccount(account,finDim1,finDim2,finDim3,finDim4,finDim5,finDim6,finDim7);

//ledgerDim = 5637144578;
//ledgerDim 0
ledgerDim = this.getLedgerAccount(account,'','','','','','','');
//5637144578
//LedgerDim = 5637144578;
// Main
//ledgerDim =DimensionStorage::getDefaultAccountForMainAccountNum
_account = account;
ledgerDim = DimensionStorage::getDefaultAccountForMainAccountNum(_account);

//LedgerDimensionDefaultAccount::getDefaultAccountforMainAccountNum(account);

//LedgerDimensionDefaultAccount getDefaultAccountForMainAccountNum
defaultDim = this.getDefaultDimension(finDim1,finDim2,finDim3,
finDim4,finDim5,finDim6,finDim7);
journalTrans.clear();
journalTrans.initFromInventJournalTable(journalTable);
journalTrans.TransDate = str2Date(conPeek(record,column1),213);
journalTrans.ItemId = localItemId;
//journalTrans.SISType = sisType;

if (conPeek(record,column17) == "SISCash")
{
journalTrans.SISType=SISType::SISCash;
}
else if (conPeek(record,column17) == "SISAR"){
journalTrans.SISType=SISType::SISAR;
}
else if (conPeek(record,column17)== "SISCompexp"){
journalTrans.SISType=SISType::SISCompexp;
}


//journalTrans.SISType=SISType::SISCash; //= conPeek(record,column17);
//journalTrans.SISType = sisType;

//journalTrans.SISType = conPeek(record,column17);
//journalTrans.SISType = str2enum(sisType, conPeek(record, column17));
//journalTrans.SISType = conPeek(record, column17);
//journalTrans.SISType =str2enum(sisType,conPeek(record, column17));
//journalTrans.SISType = conPeek(record,column17);
//journalTrans.SISType = str2enum(sisType,conPeek(record,column17));
//info(sisType)
// info(conPeek(record,column17));
// info(str2enum(SISType,conPeek(record,column17)));


itemInventDim = inventDim::find(journalTrans.ItemId);

//Product Dimension
//configuration Id
if (conPeek(record, column3) == '')
{
inventDim.configId = itemInventDim.configId;

}
else
{
inventDim.configId = conPeek(record, column3);
}

//color Id
if (conPeek(record, column4) == '')
{
inventDim.InventColorId = itemInventDim.InventColorId;

}
else
{
inventDim.InventColorId = conPeek(record, column4);
}

//size Id
if (conPeek(record, column5) == '')
{
inventDim.InventSizeId = itemInventDim.InventSizeId;

}
else
{
inventDim.InventSizeId = conPeek(record, column5);
}

//style Id
if (conPeek(record, column6) == '')
{
inventDim.InventStyleId = itemInventDim.InventStyleId;

}
else
{
inventDim.InventStyleId = conPeek(record, column6);
}

// storage dimension
// site
if (conPeek(record, column7) == '')
{
inventDim.InventSiteId = itemInventDim.InventSiteId;

}
else
{
inventDim.InventSiteId = conPeek(record, column7);
}

//warehouse
if (conPeek(record, column8) == '')
{
inventDim.InventLocationId = itemInventDim.InventLocationId;

}
else
{
inventDim.InventLocationId = conPeek(record, column8);
}

//location
if (conPeek(record, column9) == '')
{
inventDim.wMSLocationId = itemInventDim.wMSLocationId;

}
else
{
inventDim.wMSLocationId = conPeek(record, column9);
}

// tracking dimension
// Batch Id
if (conPeek(record, column10) == '')
{
inventDim.InventBatchId = itemInventDim.InventBatchId;
}
else
{
inventDim.InventBatchId = conPeek(record, column10);
}

//Serial Number
if (conPeek(record, column11) == '')
{
inventDim.InventSerialId = itemInventDim.InventSerialId;
}
else
{
inventDim.InventSerialId = conPeek(record, column11);
}


if (conPeek(record, column17) == '')
{
inventDim.InventSISType = itemInventDim.InventSISType;

}
else
{
inventDim.InventSISType = conPeek(record, column17);
}

journalTrans.inventDimId = inventDim::findOrCreate(inventDim).inventDimId;
journalTrans.LedgerDimension = ledgerDim;
journalTrans.DefaultDimension = defaultDim;
journalTrans.Qty = str2num(conPeek(record,column12));
journalTrans.CostPrice = str2num(conPeek(record,column13));
journalTrans.CostAmount = journalTrans.Qty * journalTrans.CostPrice;
journalTransData.create();
}
else
{
error(strFmt('Item %1 does not exist.', localItemId));
throw(Exception::Error);
}

}

}
catch
{
failedCtr++;
info(strFmt('Line # %1 was not saved.', row));
continue;
}

this.resetValues();

}
if (failedCtr)
{
ttsAbort;
}
else
{
journalTable.insert();
ttsCommit;
// movement journal posting

try
{
inventJournalTable = inventJournalTable::find(journalTable.JournalId);
journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
journalCheckPost.run();
}
catch
{
throw error(strFmt('Error during posting of Journal %1',
inventJournalTable.JournalId));
}
info('Uploading successfully completed.');
}
//move file
importFile.finalize();
}

**************************************

I want to change the description of the movement journal that will be uploaded. Hope you'd help :D

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Johnkrish Profile Picture
    781 on at

    Hi Spamm,
     
    If your journal is a posted journal then you can't change the description. In unposted/Open journal you can edit. So check that particular journalID which you are going to change.

    Regards,
    Johnkrish

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    Put your line of code after below line

    initFromInventJournalName

    Reason:-

    As you select JournalName, descriptions of journals come from Journal Names.

    it is overriding your below code

    journalTable.Description = "TEST DESCRIPTION";

    you are calling initFromInventJournalName after setting Description, for sure it will override,

    Fix code lines arrangement

  • Community Member Profile Picture
    on at

    yeah it did overwrite the description that's why =.= i just figured it out a while ago anyways thank you for you response sir :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans