SQL right for user group

You can maybe have some problems to test some development because, the user who test this development have some Security denied access right.

You can put in Ax, your right like the user and remove your right Admin

But, what appens when you want recover your Admin right ?

  1. Ask to an other Admin, to give you the right
  2. You can change de SQL record

For the second solution, you must connect to the SQL database (throught Management Tool). Go to the database where you are (for exemple : MyCustomer_DEV) and go to the table

dbo.USERGROUPLIST

Find your login in the table, and change one of the right you have to “Admin”.

Relaunch Ax

Label translation

You maybe use, in a report, a label in a method display ?

But when you print the message, the message still in the laguage of the user !

For change this, you can have two way :

element.design().lookupLabel(literalStr("@SYS1"), [Language_id]);

The language_id is the language of the report, but if you want, you can force a language.

Or the second, maybe more general :

SysLabel::labelId2String(literalstr('@SYS1'), 'fr');  

Find existing record in other company

Have you already have the problem to insert a record a company to an other company ?

The problem is : “I can’t know if the index exist already in the other company !”

There is two methods are create from these two posts : SysDictCode and Dilip’s blog.

The first method allow you to find the primaryKey list an make a container with the fieldId.

container findPrimaryField(Common _record)
{
    str             primaryKey;
    container       ret;
    List            primaryKeyList;
    ListEnumerator  enumerator;
    ;

    primaryKeyList  = SysDictTable::getUniqueIndexFields(_record.TableId);
    enumerator      = primaryKeyList.getEnumerator();

    while(enumerator.moveNext())
    {
        primaryKey   = strRem(enumerator.toString(), '[]');
        ret         += str2int(primaryKey);
    }

    return ret;
}

The second while check the entire table, and make a check for each fieldId in the container.

And when you found a record, you return this record.

Common findRecord(Common _record1, DataAreaId _companyId)
//Look if the index of record1 exist in record2 (they must be ine different company !)
{
    int             i;
    container       primaryKeysList;
    boolean         same;
    FieldId         fieldId;
    Common          ret;
    Common          record2;

    DictTable       dicTableLoc;
    ;

    changecompany(_companyId)
    {
        dicTableLoc     = new DictTable(_record1.TableId);
        record2         = dicTableLoc.makeRecord();
    }

    primaryKeysList = this.findPrimaryField(_record1);

    if (primaryKeysList)
    {
        while select record2
        {
            same = true;
            for (i = 1; i <= conlen(primaryKeysList); i++)
            {
                fieldId = conpeek(primaryKeysList, i);

                if (_record1.(fieldId) != record2.(fieldId))
                {
                    same = false;
                }
            }

            if (same)
            {
                ret = record2;
                break;
            }
        }
    }

    return ret;
}