Error while inserting data to SecuritySegregationOfDutiesRule Table

Hi All,

Can any one tell how to solve the following error…

“Cannot create a record in Segregation of duties rule (SecuritySegregationOfDutiesRule)
The corresponding AOS validation failed”.

Thanks in Advance…

What did you do when you got this error?

when tried to insert records in SecuritySegregationOfDutiesRule table through X++ code!!!

If possible, please show us your code.

Hi,

public void generateRules(str tableFirst,str tableSecond,str severity,str name)
{
     SkipAOSValidationPermission perm;
     date                endDate;

        TimeOfDay            endTime;
        utcDateTime          rangeEnd;



   endDate=25\5\2030;//str2Date("11,10,2020",123);
    endTime     = str2time("11:00:00 pm");
    rangeEnd =DateTimeUtil::newDateTime(endDate,endTime);
    Table2=new List(Types::String);
    Table1=new List(Types::String);

    counter1=1;


    perm = new SkipAOSValidationPermission();
     perm.assert();
    SysSecObjectsFromSecurableObject::GenerateData(tableFirst,44);
    while select Duty from dataTable group by Duty
        where dataTable.AccessRight == AccessRight::View
    {
         if (dataTable.Duty)
        {

            Table1.addEnd(dataTable.Duty);

        }
    }
    SysSecObjectsFromSecurableObject::GenerateData(tableSecond,44);
    while select Duty from dataTable group by Duty
        where dataTable.AccessRight == AccessRight::View
    {
        if (dataTable.Duty)
        {
            Table2.addEnd(dataTable.Duty);
        }
    }
    counter=Table1.elements();
    counter2=Table2.elements();
    enumeratorTable1=Table1.getEnumerator();
    while (enumeratorTable1.moveNext())
    {
          enumeratorTable2=Table2.getEnumerator();
        while (enumeratorTable2.moveNext())
        {
            while select securityDuty
                where   securityDuty.FirstSecurityTask != enumeratorTable1.current()
                        &&
                        securityDuty.SecondSecurityTask != enumeratorTable2.current()
            {
               // if (!securityDuty)
               // {

                    securityDuty.skipAosValidation(true);
                    securityDuty.Name  = name + int2str(counter1);
                    securityDuty.FirstSecurityTask=enumeratorTable1.current();
                    securityDuty.SecondSecurityTask=enumeratorTable2.current();
                //  securityDuty.Severity = str2enum(SegregationOfDutiesSeverity,severity);
                     securityDuty.ValidFrom = DateTimeUtil::getSystemDateTime();
                   // securityDuty.ValidTo = rangeEnd;
                    securityDuty.insert();
                    counter1++;
               // }
            }
        }


    }
    CodeAccessPermission::revertAssert();
    info(int2str(counter1));

}

Hi,
It will also shows date difference errors…

Hi,
Pls tell me the changes kranthi…And one more thing the class is run oon server…

The AOS validation checks if you have permissions to write to this table, which doesn’t seem to be the case.
I’m not sure what you expect from us.

If you have questions about dates, feel free to create a thread with an appropriate title and tags and explain your questions in detail there.

Hi Martin,
Thanks for ur reply…Got the answer…
The issue is Valid from and validto values of the table “SecuritySegregationofdutiesrule”…
SecuritySegregationOfDutiesRule.ValidFrom =DateTimeUtil::getSystemDateTime();
SecuritySegregationOfDutiesRule.ValidTo=DateTimeUtil::utcnow;