Axapta

You are currently browsing the articles from KomKid.Net matching the category Axapta.

Axapta : Execute SQL command

Axapta มีคำสั่ง SQL รวมอยู่ใน X++ อยู่แล้ว
แต่ถ้าอยากใช้คำสั่ง SQL อื่น ๆ เช่น ใช้ประโยชน์จาก NewID() ของ MS SQL Server เพื่อ random ก็ทำได้ ดังตัวอย่าง

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
static void Job3(Args _args)
{
    LogInProperty   Lp = new LogInProperty();
    OdbcConnection  myConnection;
    Statement       myStatement;
    ResultSet       myResult;
    str             sqlQuery;
;

    sqlQuery = 'SELECT TOP 10 * FROM CustTable ORDER BY NewID()';

    LP.setServer("Server");
    LP.setDatabase("db");
    Lp.setUsername("user");
    Lp.setPassword("password");

    try{
        myConnection = new OdbcConnection(LP);
    }
    catch{
        info("Check username/password.");
        return;
    }

    myStatement = myConnection.createStatement();
    myResult = myStatement.executeQuery(sqlQuery);

    while (myResult.next()){
        box::info(myResult.getString(1));
    }
}

Written by Komkid on October 20th, 2010 with no comments.
Read more articles on Axapta and Database and Programming.

Axapta : Find user group of current userid

กันลืม

1
2
3
4
5
6
7
8
9
 UserGroupList   userGroupList;
;
    WHILE SELECT userGroupList
    WHERE userGroupList.userId == curuserid()
//    && userGroupList.groupId == 'searchGroup';
    {
        print userGroupList.groupId;
    }
    pause;

Written by Komkid on October 20th, 2010 with no comments.
Read more articles on Axapta and Programming.

Axapta : Posting journal by code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
static void InventJournalCheckPost(Args _args)
{
InventJournalTable      inventJournalTable;
InventJournalCheckPost  journalCheckPost;    
;
ttsbegin;
inventJournalTable =  InventJournalTable::find("xxx",true);
//Remove Journal "xxx" has not been locked by system
inventJournalTable.SystemBlocked = true;
inventJournalTable.update();

journalCheckPost   =  InventJournalCheckPost::newJournalCheckPost  (JournalCheckPostType::Post,inventJournalTable);
journalCheckPost.run();

inventJournalTable.SystemBlocked = false;
inventJournalTable.update();
ttscommit;
}

Written by Komkid on February 11th, 2010 with no comments.
Read more articles on Axapta and Programming.

Axapta : Firewall config

เราสามารถตั้งค่า Axapta ให้ใช้งานผ่าน Windows Firewall ได้โดยตั้งค่า port ที่ AOS ดังรูป
axapta_aos_port

ในส่วนของ Client Config ก็ตั้งค่าในส่วนของ advance ดังรูป
axapta_client_port

แล้วก็ไป add port เพิ่มใน Windows Firewall
Windows_Firewall_Axapta_Port

Written by Komkid on January 26th, 2010 with no comments.
Read more articles on Axapta.

Axapta : Detecting Type of Variable

1
2
3
4
5
6
7
8
9
10
11
12
13
static void typeDetect(Args _args)
{
DictType    dictType;
;

print "This ID is the TypeId, not the EDT ID - ", typeId(ItemId);
print "This ID is what we need - ", typeId2ExtendedTypeId(typeId(ItemId));
print "This ID is wrong - ", new DictType(typeId(ItemId)).id();
dictType = new DictType(typeId2ExtendedTypeId(typeId(ItemId)));
print "This ID is correct - ", dictType.id();
print dictType.name();
pause;
}

Written by Komkid on December 15th, 2009 with no comments.
Read more articles on Axapta and Programming.

« Older articles

No newer articles