Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid canEditCell and editRequiresRole

    Hello,

    We're having a problem using editRequiresRole in a Datasource and we can't figure out what's causing it. Of course, it works perfectly in our development environment but works differently on our QC server. I verified that the files were installed correctly on the QC server.

    In the datasource, we have the fields set with :

    <field name="CODE" title="PAS" type="text" length="4" editRequiresRole="HSA" />
    <field name="PAL4_ID" title="PAL4" type="PAL4_ID_TYPE" editRequiresRole="HSA,MSA,MO"/>

    Our ListGrid has the following in the canEditCell function.

    canEditCell : function (rowNum, colNum) {

    // get the default editability of this cell.
    var superCanEditCell = this.Super("canEditCell", arguments); // Answers the question: Can you edit this *field* based on your role?
    // the record
    var record = this.getRecord(rowNum);
    // the field name
    var fieldName = this.getFieldName(colNum);
    // the datasource name
    var datasourceName = this.getDataSource().name;

    isc.logEcho( superCanEditCell , "[" + fieldName + "] super" );
    isc.logEcho( record["_canEdit"], "[" + fieldName + "] _canEdit" );

    // if the record has the _canEdit flag and the user cannot edit, that takes precedent over
    // everything else.
    if (record && record["_canEdit"] != null && record["_canEdit"] == false) {
    // _canEdit is a row based and answers the question: can you edit a record in this Command?
    return record["_canEdit"] && superCanEditCell;
    }

    return superCanEditCell;
    }

    When running in development, we get the following debugging:
    11:48:28.224:TMR9:WARN:Log:[CODE] super: false
    11:48:28.224:TMR9:WARN:Log:[CODE] _canEdit: true
    11:48:28.226:TMR9:WARN:Log:[PAL4_ID] super: true
    11:48:28.226:TMR9:WARN:Log:[PAL4_ID] _canEdit: true

    On the QC server and added in the same debugging. We get:
    11:59:08.485:TMR9:WARN:Log:[CODE] super: true
    11:59:08.485:TMR9:WARN:Log:[CODE] _canEdit: true
    11:59:08.566:TMR9:WARN:Log:[PAL4_ID] super: true
    11:59:08.566:TMR9:WARN:Log:[PAL4_ID] _canEdit: true

    I am assuming that calling this.Super("canEditCell", arguments) *should* return the correct boolean based on the editRequiredRole in the datasource. I'm scratching my head trying to think of what would impact this.

    Really, I'm looking for some guidance on where I should be looking. I'm not certain what the editRequiredRole uses to verify the role. I am assuming something is set in the session with those roles.

    Specifics:
    SmartClient Version: v10.1p_2019-08-29/Enterprise Deployment (built 2019-08-29)
    Browsers: Chrome, IE, Firefox.

    #2
    Hi pfincke,

    editRequiredRole is evaluated on the server in DataSourceLoader.
    The result of having or not having the role is a canEdit="false" -attribute for the field in your DataSourceLoader-call from your main HTML page. This is what your this.Super()-call consults.
    This is also the reason why you should be careful with caching the result in your Browser cache.

    Best regards
    Blama

    Comment


      #3
      Blama is correct about how editRequiresRole produces a dynamic canEdit value. So the first thing to look at is, for the user where the results seem unexpected, is that user getting the expected value when he loads the DataSource, and if not, is the user actually assigned the right roles?

      Comment

      Working...
      X