Get Dimension(Cost Center) description

One of my client requested to get display CostCenter Financial Dimension description in LedgerJournalTable.
As below screens.

Go to  CompanyName/General ledger/Journals/General journal
Click on General journal as shown below.


Click on Lines as shown below.


Select a record and click on Account Financial Dimensions shown below.


Below marked Cost Center Description “Marketing Campaign” wants to display in General Journal Form.




   1. Go to AOT/DataDictionary/Tables/LedgerJournalTable and take 
    “New Method”  as below shown.




2. Copy below code in newly created method.


//NS by Harry to get Cost Center Description on General Journal Form based on Transactions record
//BP Deviation Documented
display Name Harry_CostCenterDescription()
{
    Name                                     costCenterLoc;
    DimensionAttributeValueSetitem          item;
    Name                                    projectDim;
    DimensionAttribute                      attribute = DimensionAttribute::findByName('CostCenter');
    DimensionAttribute                      dimAttr = DimensionAttribute::findByName('CostCenter');
    DimensionAttributeValueSetItemView      valueSetItemView,valueSetItemViewLoc;
    LedgerJournalTrans                      ledgerJournalTrans,trans;
    LedgerJournalTable                      jour;
    DimensionAttributeValueGroupCombination dimAttrValueGroupCombo;
    DimensionAttributeLevelValue            dimAttrLevelValue;
    DimensionAttributeValue                 dimAttrValue;
    ;
    select ledgerJournalTrans where ledgerJournalTrans.JournalNum == this.JournalNum;

        if (ledgerJournalTrans.AccountType != LedgerJournalACType::Ledger)
        {
            select DisplayValue from valueSetItemView
            where valueSetItemView.DimensionAttributeValueSet == ledgerJournalTrans.DefaultDimension
            && valueSetItemView.DimensionAttribute == attribute.RecId;

            select valueSetItemViewLoc where valueSetItemViewLoc.DimensionAttribute == attribute.RecId
             && valueSetItemViewLoc.DimensionAttributeValueSet == ledgerJournalTrans.DefaultDimension;

           costCenterLoc =  DimensionAttributeValue::find(valueSetItemViewLoc.AttributeValueRecId).getName();
        }

        else
        {
           select trans
             where trans.JournalNum == this.JournalNum;

                while select RecId from dimAttrValueGroupCombo
                    where dimAttrValueGroupCombo.DimensionAttributeValueCombination == trans.LedgerDimension

                join displayValue from dimAttrLevelValue
                    where dimAttrLevelValue.DimensionAttributeValueGroup == dimAttrValueGroupCombo.DimensionAttributeValueGroup

                join RecId, DimensionAttribute from dimAttrValue
                    where dimAttrValue.RecId == dimAttrLevelValue.DimensionAttributeValue

                join Name from dimAttr
                    where  dimAttr.RecId == dimAttrValue.DimensionAttribute
                {
                    if (dimAttr.Name == 'CostCenter')
                    {
                        costCenterLoc = DimensionAttributeValue::find(dimAttrValue.RecId).getName();
                    }
                }
        }

    return costCenterLoc;

}

Method will be as below screen.


3. Create new Field Group as below shown.



4. Give proper Name & Label.


5. Drag our newly created method from Methods and drop it in Field Group which created above screen.

Should be like below Snap.


6. Save the table.
Then go to AOT/Forms/LedgerJournalTable and do restore for affect as below.


7. Go to Form Datasource open it in new window.


8. Select Field Group from Datasource fields and drag it & drop it in to desired form design path as below shown.


Now we can able to see Cost center as below screen.




Comments

Post a Comment