Stored Procedures [dbo].[MssWebGetConversationListByOrder]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@inSysUserIdint4
@inOrderIdint4
@inSubscribedOnlybit1
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
CREATE procedure [dbo].[MssWebGetConversationListByOrder]
    @inSysUserId int,
    @inOrderId int,
    @inSubscribedOnly bit
as
begin
    set nocount on
    select
        AccountId = SakariAccount.AccountID,
        SakariAccountPriKey = SakariAccount.SakariAccountID,
        ContactName = SakariContact.ContactName,
        ContactPhone = SakariContact.PhoneNumber,
        contactPriKey = SakariContact.SakariContactID,
        UpdateCount = isnull(ContactMessagesCount.UpdateCount,0) ,
        ScheduledMessageCount = isnull(ContactMessagesCount.ScheduledMessageCount,0),
        LastUpdatedAt = SakariContact.LastUpdatedAt
    from SakariContactOrderMap
    left outer join [dbo].udfGetUnreadAndScheduledMessageCount(@inSysUserId,@inSubscribedOnly) ContactMessagesCount on ContactMessagesCount.ContactID = SakariContactOrderMap.SakariContactFID
    inner join SakariContact on SakariContactOrderMap.SakariContactFID = SakariContact.SakariContactID
    inner join SakariAccount on SakariContact.SakariAccountFID = SakariAccount.SakariAccountID
    inner join Orders on SakariContactOrderMap.OrderFID = Orders.PriKey
    left outer join SakariContactSysuserMap on SakariContactSysuserMap.SakariContactFID = SakariContactOrderMap.SakariContactFID and
    SakariContactSysuserMap.SysuserFID = @inSysUserId
    where SakariContactOrderMap.OrderFID = @inOrderId  and
    SakariContactSysuserMap.Subscribed >= @inSubscribedOnly
    order by LastUpdatedAt desc
end
GO
GRANT EXECUTE ON  [dbo].[MssWebGetConversationListByOrder] TO [MssExec]
GO
Uses