Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

FullAuditedEntity's audit columns not getting filled #4011


User avatar
0
ajayak created

I am using saving a FullyAuditedEntity as:

var spotifyChannel = new UserSalesChannel()
            {
                AccessToken = accessToken,
                ChannelName = SalesChannelConst.Shopify,
                ChannelDomain = shop
            };
            _salesChannelRepository.Insert(spotifyChannel);

and the function is decorated with [UnitOfWork]. When I check database, the audited columns(creatorUserId etc) are null.

I am calling this function as:

using (_session.Use(tenantId.ToInt(), userId.ToInt()))
{
         await _shopifyManager.ValidateAndInstallHook(shop, code);
}

here tenantId is 2 and userId is 4. All the values are valid and AbpSession reflects correct values.


4 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Since you're in a unit of work that began without a tenant, you need to set that as well.

    using (_session.Use(tenantId.ToInt(), userId.ToInt()))
    {
        using (_unitOfWorkManager.Current.SetTenantId(tenantId.toInt()))
        {
             await _shopifyManager.ValidateAndInstallHook(shop, code);
        }
    }
    
  • User Avatar
    0
    ajayak created

    Hi @aaron,

    I tried this solution but CreatorUserId and TenantId are still saved NULL in the database.

  • User Avatar
    0
    aaron created
    Support Team

    How is _shopifyManager.ValidateAndInstallHook implemented?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ajayak,

    I think this problem is related to AbpSession.UserId & AbpSession.TenantId being null when you make a redirect to third party app and redirect back, right ?

    If so, we must understand your redirect urls first to solve this problem. I have asked about it on your other forum post #3968

    Thanks.