Values not updated in form

Hi All,

The values not updated in SA->Setup->Security->SoD->Sod Rules…But the values gets inserted to the table “Securitysegregationofdutiesrule”…

Tell me how to solve this…

Always mention the version

There are only two mandatory fields in that table, first and second security task.
I have tried by directly creating the record in that table and i can see them in form. No issue.

Can you show us your code?

Hi,
ax 2012 r2(Added in tag)

Hi Kranthi,

public void generateRules(TableName _tableFirst,
                            TableName _tableSecond,
                            SegregationOfDutiesRuleName _name,
                            AZ_SodRule_Severity _severity)
{
    #define.High('High')
    #define.Low('Low')
    #define.Medium('Medium')

    SkipAOSValidationPermission     perm;
    SysSecFlatDataTable             dataTable;
    List                            table1, table2;
    ListEnumerator                  enumeratorTable1, enumeratorTable2;
    SecuritySegregationOfDutiesRule securityDuty;
    SecurityTask                    task;

    int64 counter = 1;

    table1 = new List(Types::Int64);
    table2 = new List(Types::Int64);

    perm = new SkipAOSValidationPermission();
    perm.assert();

   // populates all security roles related to a particular table in 'SysSecFlatDatatable'
    SysSecObjectsFromSecurableObject::GenerateData(_tableFirst,44); // 44 is for table.

    while select Duty from dataTable group by Duty
        where dataTable.AccessRight == AccessRight::View
            && dataTable.Duty
    {
        select firstOnly RecId from task
            where task.AotName == dataTable.Duty;

        table1.addEnd(task.RecId);

    }

    // populates all security roles related to a particular table in 'SysSecFlatDatatable
    SysSecObjectsFromSecurableObject::GenerateData(_tableSecond,44); // 44 is for table.

    while select Duty from dataTable group by Duty
        where dataTable.AccessRight == AccessRight::View
            && dataTable.Duty
    {
        select firstOnly RecId from task
            where task.AotName == dataTable.Duty;

        table2.addEnd(task.RecId);
    }

    enumeratorTable1 = table1.getEnumerator();

    while (enumeratorTable1.moveNext())
    {
        enumeratorTable2 = table2.getEnumerator();

        while (enumeratorTable2.moveNext())
        {
            select firstOnly RecId from securityDuty
                where securityDuty.FirstSecurityTask == enumeratorTable1.current()
                    && securityDuty.SecondSecurityTask == enumeratorTable2.current();

            if (!securityDuty.RecId)
            {
                securityDuty.skipAosValidation(true);
                securityDuty.Name  = _name + int642str(counter);
                securityDuty.FirstSecurityTask = enumeratorTable1.current();
                securityDuty.SecondSecurityTask = enumeratorTable2.current();

                if (_severity == #High)
                {
                    securityDuty.Severity = SegregationOfDutiesSeverity::High;
                }
                else if(_severity == #Low)
                {
                    securityDuty.Severity = SegregationOfDutiesSeverity::Low;
                }
                else if (_severity == #Medium)
                {
                    securityDuty.Severity = SegregationOfDutiesSeverity::Medium;
                }

                securityDuty.ValidFrom = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(), DateTimeUtil::getUserPreferredTimeZone());
                securityDuty.ValidTo = DateTimeUtil::maxValue();
                securityDuty.insert();
                counter++;
            }
            else
            {
                counter++;
            }
        }
    }

    CodeAccessPermission::revertAssert();
}

Does the values properly updated on the table? Check the validFrom and to.

Hi Kranthi,

Got d answer…
securityDuty.ValidFrom = DateTimeUtil::utcNow();