Open Closed

LASTMODIFIERID IS UPDATING NULL VALUE #5005


User avatar
0
shijo created
  • ABP Framework version: v7.0.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:" We are updating some records through distributed events, other than LastmofierID all values are updating perfectly. I tried to set ClaimsPrincipal also but not reflecting. Sample method added below,
        [UnitOfWork]
        public async Task HandleEventAsync(APIBulkOperationEto eventData)
        {
            _currentTenant.Change(eventData.TenantId);
            var newPrincipal = new ClaimsPrincipal(
                                    new ClaimsIdentity(
                                        new Claim[]
                                        {
                                                    new Claim(AbpClaimTypes.UserId, eventData.CreatorId.ToString()),
                                                    new Claim(AbpClaimTypes.TenantId, eventData.TenantId.ToString()),
                                                    new Claim(AbpClaimTypes.UserName, "admin")
                                        }
                                    )
                                 );

             var detail = await _bulkActionDetailRepository.GetAsync(x => x.BulkActionId == eventData.BulkActionId && x.FileDescriptorId == eventData.FileDescriptorId);
                    if (detail != null)
                    {
                        detail.Status = eventData.Status;
                        detail.StatusDetail = eventData.StatusMessage;
                        await _bulkActionDetailRepository.UpdateAsync(detail, true);
                    }
        }

2 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please use using for _currentTenant and ICurrentPrincipalAccessor

    using(_currentTenant.Change(eventData.TenantId)) 
    {
      var newPrincipal = new ClaimsPrincipal(
        new ClaimsIdentity(
          new Claim[] {
            new Claim(AbpClaimTypes.UserId, eventData.CreatorId.ToString()),
              new Claim(AbpClaimTypes.TenantId, eventData.TenantId.ToString()),
              new Claim(AbpClaimTypes.UserName, "admin")
          }
        )
      );
      
      using(_currentPrincipalAccessor.Change(newPrincipal)) 
      {
        var detail = await _bulkActionDetailRepository.GetAsync(x => x.BulkActionId == eventData.BulkActionId && x.FileDescriptorId == eventData.FileDescriptorId);
        if (detail != null) 
        {
          detail.Status = eventData.Status;
          detail.StatusDetail = eventData.StatusMessage;
          await _bulkActionDetailRepository.UpdateAsync(detail, true);
        }
      }
    }
    
    
  • User Avatar
    0
    shijo created

    Thanks. Its working.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on July 14, 2025, 11:57