mardi 19 avril 2011

How to create method find in a table

Follow this example:

static Thy_DimensionsNivels find(ProjCategoryId _projCategoryId, boolean _forUpdate = false)
{
    Thy_DimensionsNivels   thy_DimensionsNivels = null;
    ;

    Thy_DimensionsNivels.selectForUpdate(_forUpdate);

    if (_projCategoryId)
    {
        select firstonly thy_DimensionsNivels
                index hint DimensionIdx
                    where thy_DimensionsNivels.ConcatNum  == _projCategoryId;
    }

    return thy_DimensionsNivels;
}

Or this one in the inventDim Table 

static public InventDim find(InventDimId inventDimId, boolean _forupdate = false)
{
    InventDim inventDim;
    ;

    if (inventDimId)
    {
        if (_forupdate)
            inventDim.selectForUpdate(_forupdate);

        select firstonly inventDim
            index hint DimIdIdx
            where inventDim.InventDimId  == inventDimId;
    }

    return inventDim;
}

How to create method exist in a table

Follow this example

public static boolean exist(String255 _concatNum)
{
    boolean found;
    ;

    found = (select firstonly
                 RecId
            from
                 Thy_dimensionsNivels
             where
                 Thy_dimensionsNivels.ConcatNum == _concatNum).RecId != 0;

    return found;
}

lundi 18 avril 2011

How to update vendor addresses in Dynamics AX

static void J1A_UpdateVendAddressType(Args _args)
{
VendTable vendTab; // Replace VendTable with CustTable when run this for customers.
DirPartyTable dirPartyTab;
Address addTab;
;
ttsbegin;
while select vendTab
join dirPartyTab
join forupdate addTab
where vendTab.PartyId == dirPartyTab.PartyId &&
addTab.AddrTableId == dirPartyTab.TableId &&
addTab.AddrRecId == dirPartyTab.RecId
{
      if(addTab.Name == 'Birincil Adres')
     {
        addTab.type = AddressType::Payment;
       addTab.update();
     }
}
ttscommit;
}

How to import vendors to VendTable in Dynamics AX

Here are the steps:

1. Import vendor records with a PartyID (I used vendor id)

2. Import records into the DirPartyTable

Type = Organisation
Language=EN-GB (for example)
PartyID=VendTable.AccountNum

3. Import records into the Address table (export dirpartytable to get recid)

AddrRecId=DirPartyTable.RecID
AddrTableId=2303 
STREET=address (i.e added char(10)s in excel for carriage returns - I know
there are other ways)

4. Import records into PartyAddressRelationship (export address to get recid)

Status=active
PartyID = vendtable.partyid

5. Import records into PartyAddressRelationshipMapping (export
partyaddressrelationship to get recid)

addressrecid=address.recid
partyaddressrelationshiprecid=partyaddressrelationship.

vendredi 15 avril 2011

How to allow creating in a grid of a form only when choosing value of another field

Try this

public void create(boolean _append = false)
{
     if( InventFamilyId1.valueStr()!= "")
     {
        super(_append);
     }
     else
     {
        Warning("@THY101");
     }
}

How to initilize a field in a form when all records in the grid are deleted

You can use this

public void delete()
{
    super();
    if (!Thy_InventItemPrintParameters::exist(Thy_InventItemPrintParameters.ItemId))
    {
        InventFamilyId1.text("");
        InventFamilyId1.enabled(Noyes::Yes);
        InventFamilyId1.mandatory(Noyes::Yes);
    }
}