From 6b010023f7d21ce8c087d1e9657f7d1f89ac2ec0 Mon Sep 17 00:00:00 2001 From: Rasmus Steine Olsen <111959793+olsenrasmus@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:19:33 +0200 Subject: [PATCH 1/7] . --- .../main/default/classes/HOT_ClaimHandler.cls | 8 ++++ .../classes/HOT_NotificationService.cls | 48 +++++++++++++++++++ .../HOT_NotificationService.cls-meta.xml | 5 ++ .../HOT_NotifyNAV.notiftype-meta.xml | 8 ++++ 4 files changed, 69 insertions(+) create mode 100644 force-app/main/default/classes/HOT_NotificationService.cls create mode 100644 force-app/main/default/classes/HOT_NotificationService.cls-meta.xml create mode 100644 force-app/main/default/notificationtypes/HOT_NotifyNAV.notiftype-meta.xml diff --git a/force-app/main/default/classes/HOT_ClaimHandler.cls b/force-app/main/default/classes/HOT_ClaimHandler.cls index 398d2af6..78f7989f 100644 --- a/force-app/main/default/classes/HOT_ClaimHandler.cls +++ b/force-app/main/default/classes/HOT_ClaimHandler.cls @@ -1,14 +1,22 @@ public without sharing class HOT_ClaimHandler extends MyTriggers { public override void onAfterInsert() { + List notifyNAVNotRegisteredReader = new List(); + Set accountIds = new Set(); for (HOT_Claim__c claim : (List) records) { accountIds.add(claim.Claimant__c); + if(claim.IsLos__c==false){ + notifyNAVNotRegisteredReader.add(claim.Id); + } } if (accountIds.size() > 0) { // Call out to KRR through Queuable Apex HOT_KRRAccountCalloutQueuable krr = new HOT_KRRAccountCalloutQueuable(accountIds); System.enqueueJob(krr); } + if (!notifyNAVNotRegisteredReader.isEmpty()) { + HOT_NotificationService.NotifyNAV(notifyNAVNotRegisteredReader); + } } public override void onAfterUpdate(Map triggerOldMap) { List claimsToNotifyUserOnDeclinedStatus = new List(); diff --git a/force-app/main/default/classes/HOT_NotificationService.cls b/force-app/main/default/classes/HOT_NotificationService.cls new file mode 100644 index 00000000..a3bb8a1a --- /dev/null +++ b/force-app/main/default/classes/HOT_NotificationService.cls @@ -0,0 +1,48 @@ +public without sharing class HOT_NotificationService { + @Future + public static void NotifyNAV(List claimIds) { + List claims = [ + SELECT Id, Name + FROM HOT_Claim__c + WHERE Id IN :claimIds + ]; + List navUsers =[SELECT Id FROM User WHERE Id in (SELECT userorgroupid from groupmember where group.name = 'HOT LOS Saksbehandler')]; + + for(HOT_Claim__c claim : claims){ + for(User user : navUsers){ + Set recipients = new Set(); + recipients.add(user.Id); + Messaging.CustomNotification notification = new Messaging.CustomNotification(); + notification.setTitle('Lesehjelp uten ressursnummer'); + notification.setBody('Lesehjelp uten ressursnummer har sendt inn et nytt krav'); + notification.setNotificationTypeId(getCustomNotificationType('HOT_NotifyNAV').Id); + notification.setTargetId(claim.Id); + sendNotification(notification, recipients, (SObject) claim); // send med parameter for denne + } + } + } + public static CustomNotificationType getCustomNotificationType(String devName) { + CustomNotificationType notificationType = [ + SELECT Id, DeveloperName + FROM CustomNotificationType + WHERE DeveloperName = :devName + ]; + return notificationType; + } + public static void sendNotification( + Messaging.CustomNotification notification, + Set recipients, + SObject record + ) { + LoggerUtility logger = new LoggerUtility(); + + if (recipients != null && recipients.size() > 0) { + try { + notification.send(recipients); + } catch (Exception e) { + logger.exception(e, record, CRM_ApplicationDomain.Domain.HOT); + logger.publishSynch(); + } + } + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/HOT_NotificationService.cls-meta.xml b/force-app/main/default/classes/HOT_NotificationService.cls-meta.xml new file mode 100644 index 00000000..9bbf7b4e --- /dev/null +++ b/force-app/main/default/classes/HOT_NotificationService.cls-meta.xml @@ -0,0 +1,5 @@ + + + 56.0 + Active + \ No newline at end of file diff --git a/force-app/main/default/notificationtypes/HOT_NotifyNAV.notiftype-meta.xml b/force-app/main/default/notificationtypes/HOT_NotifyNAV.notiftype-meta.xml new file mode 100644 index 00000000..9dccb8ad --- /dev/null +++ b/force-app/main/default/notificationtypes/HOT_NotifyNAV.notiftype-meta.xml @@ -0,0 +1,8 @@ + + + HOT_NotifyNAV + true + HOT_NotifyNAV + false + false + From 11c63955e0acd632bad206e8622a0c6467f91778 Mon Sep 17 00:00:00 2001 From: Rasmus Steine Olsen <111959793+olsenrasmus@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:20:52 +0200 Subject: [PATCH 2/7] Update HOT_NotificationService.cls --- force-app/main/default/classes/HOT_NotificationService.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/force-app/main/default/classes/HOT_NotificationService.cls b/force-app/main/default/classes/HOT_NotificationService.cls index a3bb8a1a..63e0e188 100644 --- a/force-app/main/default/classes/HOT_NotificationService.cls +++ b/force-app/main/default/classes/HOT_NotificationService.cls @@ -17,7 +17,7 @@ public without sharing class HOT_NotificationService { notification.setBody('Lesehjelp uten ressursnummer har sendt inn et nytt krav'); notification.setNotificationTypeId(getCustomNotificationType('HOT_NotifyNAV').Id); notification.setTargetId(claim.Id); - sendNotification(notification, recipients, (SObject) claim); // send med parameter for denne + sendNotification(notification, recipients, (SObject) claim); } } } From 69db0cd8d1a5c2c9f148db392474b3858da3b160 Mon Sep 17 00:00:00 2001 From: Rasmus Steine Olsen <111959793+olsenrasmus@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:01:00 +0200 Subject: [PATCH 3/7] . --- .../main/default/classes/HOT_ClaimHandler.cls | 7 ++- .../classes/HOT_NotificationService.cls | 46 ++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/force-app/main/default/classes/HOT_ClaimHandler.cls b/force-app/main/default/classes/HOT_ClaimHandler.cls index 78f7989f..0891fe01 100644 --- a/force-app/main/default/classes/HOT_ClaimHandler.cls +++ b/force-app/main/default/classes/HOT_ClaimHandler.cls @@ -3,19 +3,24 @@ public without sharing class HOT_ClaimHandler extends MyTriggers { List notifyNAVNotRegisteredReader = new List(); Set accountIds = new Set(); + List claimIds = new List(); for (HOT_Claim__c claim : (List) records) { accountIds.add(claim.Claimant__c); if(claim.IsLos__c==false){ notifyNAVNotRegisteredReader.add(claim.Id); } + claimIds.add(claim.Id); } if (accountIds.size() > 0) { // Call out to KRR through Queuable Apex HOT_KRRAccountCalloutQueuable krr = new HOT_KRRAccountCalloutQueuable(accountIds); System.enqueueJob(krr); } + if (!claimIds.isEmpty()) { + HOT_NotificationService.NotifyNAVNotNoEntitlementOnUser(claimIds); + } if (!notifyNAVNotRegisteredReader.isEmpty()) { - HOT_NotificationService.NotifyNAV(notifyNAVNotRegisteredReader); + HOT_NotificationService.NotifyNAVNotRegisteredReader(notifyNAVNotRegisteredReader); } } public override void onAfterUpdate(Map triggerOldMap) { diff --git a/force-app/main/default/classes/HOT_NotificationService.cls b/force-app/main/default/classes/HOT_NotificationService.cls index 63e0e188..b3e05539 100644 --- a/force-app/main/default/classes/HOT_NotificationService.cls +++ b/force-app/main/default/classes/HOT_NotificationService.cls @@ -1,6 +1,50 @@ public without sharing class HOT_NotificationService { @Future - public static void NotifyNAV(List claimIds) { + public static void NotifyNAVNotNoEntitlementOnUser(List claimIds) { + List claims = [ + SELECT Id, Name, Account__c + FROM HOT_Claim__c + WHERE Id IN :claimIds + ]; + Set accountIds = new Set(); + Map claimMap = new Map(); + for(HOT_Claim__c claim : claims){ + accountIds.add(claim.Account__c); + claimMap.put(claim.Account__c, claim); + } + List entitlements = [ + SELECT Id, Account__c + FROM HOT_Entitlement__c + WHERE Account__c IN :accountIds + ]; + + Set entitledAccountIds = new Set(); + for(HOT_Entitlement__c entitlement : entitlements){ + entitledAccountIds.add(entitlement.Account__c); + } + List navUsers =[SELECT Id FROM User WHERE Id in (SELECT userorgroupid from groupmember where group.name = 'HOT LOS Saksbehandler')]; + + for(Id accountId : accountIds){ + if (!entitledAccountIds.contains(accountId)) { + HOT_Claim__c claim = claimMap.get(accountId); + if (claim != null) { + for(User user : navUsers){ + Set recipients = new Set(); + recipients.add(user.Id); + Messaging.CustomNotification notification = new Messaging.CustomNotification(); + notification.setTitle('Lesehjelp har sendt inn krav på en bruker som ikke har noen vedtak'); + notification.setBody('Legg på vedtak på brukeren'); + notification.setNotificationTypeId(getCustomNotificationType('HOT_NotifyNAV').Id); + notification.setTargetId(claim.Id); + sendNotification(notification, recipients, (SObject) claim); + } + } + } + } +} + + @Future + public static void NotifyNAVNotRegisteredReader(List claimIds) { List claims = [ SELECT Id, Name FROM HOT_Claim__c From 8354be42d0c6e3a60e27873738dbeb78eb1a6591 Mon Sep 17 00:00:00 2001 From: Rasmus Steine Olsen <111959793+olsenrasmus@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:03:25 +0200 Subject: [PATCH 4/7] Update hot_claimantClaimList.html --- .../lwc/hot_claimantClaimList/hot_claimantClaimList.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/force-app/main/default/lwc/hot_claimantClaimList/hot_claimantClaimList.html b/force-app/main/default/lwc/hot_claimantClaimList/hot_claimantClaimList.html index 781bea7e..8bf5baf4 100644 --- a/force-app/main/default/lwc/hot_claimantClaimList/hot_claimantClaimList.html +++ b/force-app/main/default/lwc/hot_claimantClaimList/hot_claimantClaimList.html @@ -111,8 +111,8 @@

Mine innsendte krav

> advarsel-ikon
- Vi mangler kontaktinformasjon til personen du har vært lesehjelp for, som dermed da ikke - har fått beskjed om at du har sendt inn et nytt krav. + Vi mangler kontaktinformasjon til personen du har vært lesehjelp for, som da ikke har + fått beskjed om at du har sendt inn et nytt krav.
From f2da06bec40b74f6d62442554e886d091089cbe0 Mon Sep 17 00:00:00 2001 From: Rasmus Steine Olsen <111959793+olsenrasmus@users.noreply.github.com> Date: Wed, 5 Jun 2024 13:29:32 +0200 Subject: [PATCH 5/7] . --- force-app/main/default/classes/HOT_NotificationService.cls | 4 ++-- ...type-meta.xml => HOT_ClaimNotification.notiftype-meta.xml} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename force-app/main/default/notificationtypes/{HOT_NotifyNAV.notiftype-meta.xml => HOT_ClaimNotification.notiftype-meta.xml} (64%) diff --git a/force-app/main/default/classes/HOT_NotificationService.cls b/force-app/main/default/classes/HOT_NotificationService.cls index b3e05539..b0ba0339 100644 --- a/force-app/main/default/classes/HOT_NotificationService.cls +++ b/force-app/main/default/classes/HOT_NotificationService.cls @@ -34,7 +34,7 @@ public without sharing class HOT_NotificationService { Messaging.CustomNotification notification = new Messaging.CustomNotification(); notification.setTitle('Lesehjelp har sendt inn krav på en bruker som ikke har noen vedtak'); notification.setBody('Legg på vedtak på brukeren'); - notification.setNotificationTypeId(getCustomNotificationType('HOT_NotifyNAV').Id); + notification.setNotificationTypeId(getCustomNotificationType('HOT_ClaimNotification').Id); notification.setTargetId(claim.Id); sendNotification(notification, recipients, (SObject) claim); } @@ -59,7 +59,7 @@ public without sharing class HOT_NotificationService { Messaging.CustomNotification notification = new Messaging.CustomNotification(); notification.setTitle('Lesehjelp uten ressursnummer'); notification.setBody('Lesehjelp uten ressursnummer har sendt inn et nytt krav'); - notification.setNotificationTypeId(getCustomNotificationType('HOT_NotifyNAV').Id); + notification.setNotificationTypeId(getCustomNotificationType('HOT_ClaimNotification').Id); notification.setTargetId(claim.Id); sendNotification(notification, recipients, (SObject) claim); } diff --git a/force-app/main/default/notificationtypes/HOT_NotifyNAV.notiftype-meta.xml b/force-app/main/default/notificationtypes/HOT_ClaimNotification.notiftype-meta.xml similarity index 64% rename from force-app/main/default/notificationtypes/HOT_NotifyNAV.notiftype-meta.xml rename to force-app/main/default/notificationtypes/HOT_ClaimNotification.notiftype-meta.xml index 9dccb8ad..93d46f45 100644 --- a/force-app/main/default/notificationtypes/HOT_NotifyNAV.notiftype-meta.xml +++ b/force-app/main/default/notificationtypes/HOT_ClaimNotification.notiftype-meta.xml @@ -1,8 +1,8 @@ - HOT_NotifyNAV + HOT_ClaimNotification true - HOT_NotifyNAV + HOT_ClaimNotification false false From 84748b26e7a371e3641856426b39ff4921cecce4 Mon Sep 17 00:00:00 2001 From: Rasmus Steine Olsen <111959793+olsenrasmus@users.noreply.github.com> Date: Wed, 5 Jun 2024 13:31:27 +0200 Subject: [PATCH 6/7] . --- force-app/main/default/classes/HOT_ClaimHandler.cls | 4 ++-- ...tificationService.cls => HOT_ClaimNotificationService.cls} | 2 +- ...cls-meta.xml => HOT_ClaimNotificationService.cls-meta.xml} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename force-app/main/default/classes/{HOT_NotificationService.cls => HOT_ClaimNotificationService.cls} (98%) rename force-app/main/default/classes/{HOT_NotificationService.cls-meta.xml => HOT_ClaimNotificationService.cls-meta.xml} (100%) diff --git a/force-app/main/default/classes/HOT_ClaimHandler.cls b/force-app/main/default/classes/HOT_ClaimHandler.cls index 0891fe01..2be8adf7 100644 --- a/force-app/main/default/classes/HOT_ClaimHandler.cls +++ b/force-app/main/default/classes/HOT_ClaimHandler.cls @@ -17,10 +17,10 @@ public without sharing class HOT_ClaimHandler extends MyTriggers { System.enqueueJob(krr); } if (!claimIds.isEmpty()) { - HOT_NotificationService.NotifyNAVNotNoEntitlementOnUser(claimIds); + HOT_ClaimNotificationService.NotifyNAVNotNoEntitlementOnUser(claimIds); } if (!notifyNAVNotRegisteredReader.isEmpty()) { - HOT_NotificationService.NotifyNAVNotRegisteredReader(notifyNAVNotRegisteredReader); + HOT_ClaimNotificationService.NotifyNAVNotRegisteredReader(notifyNAVNotRegisteredReader); } } public override void onAfterUpdate(Map triggerOldMap) { diff --git a/force-app/main/default/classes/HOT_NotificationService.cls b/force-app/main/default/classes/HOT_ClaimNotificationService.cls similarity index 98% rename from force-app/main/default/classes/HOT_NotificationService.cls rename to force-app/main/default/classes/HOT_ClaimNotificationService.cls index b0ba0339..ca396fb0 100644 --- a/force-app/main/default/classes/HOT_NotificationService.cls +++ b/force-app/main/default/classes/HOT_ClaimNotificationService.cls @@ -1,4 +1,4 @@ -public without sharing class HOT_NotificationService { +public without sharing class HOT_ClaimNotificationService { @Future public static void NotifyNAVNotNoEntitlementOnUser(List claimIds) { List claims = [ diff --git a/force-app/main/default/classes/HOT_NotificationService.cls-meta.xml b/force-app/main/default/classes/HOT_ClaimNotificationService.cls-meta.xml similarity index 100% rename from force-app/main/default/classes/HOT_NotificationService.cls-meta.xml rename to force-app/main/default/classes/HOT_ClaimNotificationService.cls-meta.xml From 401c0c5d020693db80d38731a4ad160c7cb1da84 Mon Sep 17 00:00:00 2001 From: Rasmus Steine Olsen <111959793+olsenrasmus@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:23:37 +0200 Subject: [PATCH 7/7] . --- force-app/main/default/classes/HOT_ClaimHandler.cls | 2 +- force-app/main/default/classes/HOT_ClaimNotificationService.cls | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/force-app/main/default/classes/HOT_ClaimHandler.cls b/force-app/main/default/classes/HOT_ClaimHandler.cls index 2be8adf7..656db3c7 100644 --- a/force-app/main/default/classes/HOT_ClaimHandler.cls +++ b/force-app/main/default/classes/HOT_ClaimHandler.cls @@ -17,7 +17,7 @@ public without sharing class HOT_ClaimHandler extends MyTriggers { System.enqueueJob(krr); } if (!claimIds.isEmpty()) { - HOT_ClaimNotificationService.NotifyNAVNotNoEntitlementOnUser(claimIds); + HOT_ClaimNotificationService.NotifyNAVNoEntitlementOnUser(claimIds); } if (!notifyNAVNotRegisteredReader.isEmpty()) { HOT_ClaimNotificationService.NotifyNAVNotRegisteredReader(notifyNAVNotRegisteredReader); diff --git a/force-app/main/default/classes/HOT_ClaimNotificationService.cls b/force-app/main/default/classes/HOT_ClaimNotificationService.cls index ca396fb0..8eea3d01 100644 --- a/force-app/main/default/classes/HOT_ClaimNotificationService.cls +++ b/force-app/main/default/classes/HOT_ClaimNotificationService.cls @@ -1,6 +1,6 @@ public without sharing class HOT_ClaimNotificationService { @Future - public static void NotifyNAVNotNoEntitlementOnUser(List claimIds) { + public static void NotifyNAVNoEntitlementOnUser(List claimIds) { List claims = [ SELECT Id, Name, Account__c FROM HOT_Claim__c