Topic
  • 3 replies
  • Latest Post - ‏2012-12-11T12:33:18Z by cglockner
SystemAdmin
SystemAdmin
24948 Posts

Pinned topic Why i can't build an Entity directly?

‏2012-12-10T07:52:52Z |
"Feature" Entity contains a reference list field named "MappingTable" which refer to an Entity "Feature_MappingTables".

When call method session->BuildEntity("Feature_MappingTables"),a error will be throw:
Permission denied for user Admin to perform action Submit (of type SUBMIT).

But using same account, I can build "Feature_MappingTables" Entity inside of "Feature" Entity by manually operation,shown as the attachment picture.

My final purpose is to set the fieldvalue of "MappingTable" ,but i failed by trying many times.

How should i do?
  • Lumart
    Lumart
    87 Posts

    Re: Why i can't build an Entity directly?

    ‏2012-12-10T10:18:09Z  
    Please, verify the entity name.
    Are you sure that the record you are trying to create is named Feature_MappingTables ?
    According to the picture, it looks like the entity name is Feature_BlockMappingTable (see the label on the top window bar).
    Anyway, a user is allowed or denied the permission to create a record according to the rules in the ACCESS_CONTROL hook of the Submit action (I mean Submit as an action type, not as the action name, the action might be named Create, for instance), so you should also verify what those rulese are stating.
  • SystemAdmin
    SystemAdmin
    24948 Posts

    Re: Why i can't build an Entity directly?

    ‏2012-12-11T09:43:56Z  
    "Feature_MappingTables" is just a clerical error when i wrote this thread.
    In my code,i actually use "Feature_BlockMappingTable".

    I post another picture which shows the Action of "Feature_BlockMappingTable" Entity.
    The "Accesee Control" field of "SUBMIT" type is "perl",and we can also see its script.

    If i want to set the fieldvalue of "MappingTable" in "Feature" Entity,should i take the below steps?:
    1. set the Accesee Control to "All Users"
    2. $BlockEntity=$session->BuildEntity("Feature_BlockMappingTable");
    3. setfieldvalue of $BlockEntity and save it.
    4. $FeatureEntity=$session->BuildEntity("Feature")
    5. $FeatureEntity->AddFieldValue("MappingTables", "$BlockEntity"); # the field MappingTables is a reference list.

    Am I right?
  • cglockner
    cglockner
    345 Posts

    Re: Why i can't build an Entity directly?

    ‏2012-12-11T12:33:18Z  
    "Feature_MappingTables" is just a clerical error when i wrote this thread.
    In my code,i actually use "Feature_BlockMappingTable".

    I post another picture which shows the Action of "Feature_BlockMappingTable" Entity.
    The "Accesee Control" field of "SUBMIT" type is "perl",and we can also see its script.

    If i want to set the fieldvalue of "MappingTable" in "Feature" Entity,should i take the below steps?:
    1. set the Accesee Control to "All Users"
    2. $BlockEntity=$session->BuildEntity("Feature_BlockMappingTable");
    3. setfieldvalue of $BlockEntity and save it.
    4. $FeatureEntity=$session->BuildEntity("Feature")
    5. $FeatureEntity->AddFieldValue("MappingTables", "$BlockEntity"); # the field MappingTables is a reference list.

    Am I right?
    Hello,

    You can delete the access control and set it to all users, but you can also, in the hook you're using to create the entity, call
    
    $session->SetNameValue(
    "SV_Feature", 
    "1")
    


    This will set the session variable "SV_Feature" to 1, which is what the Access Control hook checks for.

    -Christian