среда, 9 декабря 2015 г.

How to hide ranges in query for dialog RunBase

I've got the same problem. 

And untull today I resolve this problem by adding 

qbr.addrange()  for index fields on table and after that make them dissapear throgh 

qbr.rangestatus(RangeStatus::Hidden).

But today I found new solution for hiding index fields as ranges in dialog.


All you need it override showIndexFields() method and depend on what ranges in datasource(table) you want to hide, you must return false for those ones.


Here's an example

public boolean showIndexFields(TableId id)
{
    boolean ret = true;
    switch (id)
    {
        case tableNum(DirPerson) :
            ret = false;
            break;
        case tableNum(HcmEmployment) :
            ret = false;
            break;
    }
    return ret;
}

If you'll have any questions, please , send an email, I'll be happy to answer on them!

пятница, 29 мая 2015 г.

How to insert record in the end of the grid

Hello everyone!
I want to share with you some useful information.
I need to insert new records in the end of the grid. The DAX standatd behaviour's don't let this.
So I have found solution, how to do this.
Here's code, you just need to override create method on needed datasource:

public void create(boolean _append = true)
{
    this.last();
    super(_append);
}

The mose important in this code -  _append property.
By default it has false value, but we need to change it on "true"  otherwise our code won't work.

Please, if you have any questions - comment or send me e-mail!
Thanks!

четверг, 28 мая 2015 г.

How to show value in preview pane only for selected viewFilter

Hi, guys!
Today I want to show you, how you can set value for Preview Pane - Form Part special values or how you can get it visible and empty if you need this.
Here is code example for how make preview pane visible\hide:
void previewPaneVisible(boolean _show)
{
    FormRun         part;
    PartList        partList;
    ;
    partList = new PartList(Element);
    if (_show ^ (partList.partCount() > 0))
    {
       element.task(4478));
    }
}

And here's solution for  make preview pane empty on some cases:

void showPreviewRecords(boolean _show)
{
    int idx;
    Object part;
    PartList partList;
    partList = new PartList(element);
    for(idx = 1; idx<= partList.partCount(); idx++)
    {
        part = partList.getPartById(idx);
       if((part is FormRun) && (part.name() == identifieStr(yourListPageForm)))
       {
            part.ParmShowEmptyGrid(!_show);
       }
   }
}

If you have any questions  - please, comment or send me e-mail.

Thanks! 

вторник, 5 мая 2015 г.

Multiselect Lookup form AX 2012

Hi everyone.
If you need to create lookup on form, but you can't use standard SysTableLookup class for create it, you can create your own lookup form for it.

In my case, I was needed to bring out 2 cloumns, which I took from View.
Also I need multiselect choise.

What you need to do:

Overrun init, run and closeOk methods on form:

init:
Spoiler:
super();
if(element.args() && element.args().caller() && element.args().dataset() == tableNum(ParentTable))
    {
        callerTable = element.args().record();
    }
run:
super();
this.setSelectedGroup();
closeOk:
Spoiler:
FormStringControl       callerFormControl       = SysTableLookup::getCallerControl(element.args());
    RefRecId                groupRefRecId;
    str                     selectedGroups;
    int                     lenOfStr;
    int                     i;
    container               courtesyCopyData;
    courtesyCopyData = element.getSelectedCopyGroups();
 
    //callerTable.CoutersyCopyGroupContainer = element.getSelectedCopyGroups();
    for (i = 1; i <= conLen(courtesyCopyData); i++)
    {
        groupRefRecId     = conPeek(courtesyCopyData, i);
        selectedGroups += Table::findByRecId(groupRefRecId).GroupId + #comma;
    }
    if(selectedGroups)
    {
        lenOfStr = strLen(selectedGroups);
        selectedGroups = strDel(selectedGroups, lenOfStr, 1);
    }
    callerTable.CoutersyCopyGroup = selectedGroups;
    if(callerFormControl)
    {
        callerFormControl.text(callerTable.CoutersyCopyGroup);
    }
    super(); 

Also, you need to create some methods for set selected records and insert them into table and get these selected records to your lookup:


Spoiler:
public container getSelectedCopyGroups()
{
    Table                               copyGroup;
    container                          selectedCopyGroups;
    int                                     i = 1;
    copyGroup = Table_ds.getNext(true);
    while (copyGroup)
    {
        selectedCopyGroups = conIns(selectedCopyGroups, i, copyGroup.RecId);
        i++;
        copyGroup = Table_ds.getNext();
    }
    return selectedCopyGroups;
}
public void setSelectedGroup()
{
    container   courtesyCopyData;
    int         i;
    RefRecId    RefRecId;
    courtesyCopyData = Table::findReferenceRecipientRecord(callerTable.RecId, CourtesyCopyType::CoutersyCopyGroup).CourtesyCopyData;
    if(conLen(courtesyCopyData))
    {
        for (i = 1; i <= conLen(courtesyCopyData); i++)
        {
            RefRecId = conPeek(courtesyCopyData, i);
            Table_ds.markRecord(Table::findByRecId(RefRecId), 1);
        }
    }
If you have any questions, I will be happy to answer them. 

How to get string value with coma in View Dax 2012

Hello everyone!
Today I want to share with you some useful information.
I had a task:
get the value from table1 and bring them into one string with coma separator.
First I wanted to use display method, but display methods don't work in Views.
And I wrote the query for String Computed column, that returns the correct string value, which I needed.
Here's the code:

public static server str getLiveUserIdValue()
{
    str     curRecId = SysComputedColumn::returnField(tableStr(table), identifierStr(table), fieldStr(table, field));
    return '(select STUFF((select \',\'+ UserId from table where table.recid='+curRecId+' for xml path(\'\')), 1,1, \'\') as lst )';
}

This code hepled me to return correct value.
Hope, it'll be usefull for someone! 

пятница, 17 апреля 2015 г.

How to update parrent form current form

We have form1 - parent form and form2 - child form, which opens from form1.
If you want do autoRefresh form1, you should use this code:

This code must be populated on Close() method form2
if(element.args().caller() is FormRun && element.args().caller().name() == formStr(Form1))
    {
        formRun = element.args().caller();
        if(formRun)
        {
            formRun.task(#taskF5);
        }
    }

How to get value divided by symbol AX 2012

Hi everyone.
Today I must create method, which had to create a list from current string value , divided by slash (/).
And I have written this code:

#Characters_CN
    List            list = new List(Types::String);
    ListIterator    iterator;
    container       packCon;
    int             slashCount = 0;

    list = strSplit(this.CoverSheetURL, #slash); //this.CoverSheetURL - your string value       iterator = new ListIterator(list);
    while (iterator.more())
    {
        packCon += iterator.value();
        slashCount++;
        iterator.next();
    }
    return conPeek(packCon, slashCount);


I hope, it will be useful for you :)