• Francisco Javier Ortegon Tesias
  • NEWBIE
  • 5 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Refused to display  in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".

How to fix this issue,Due to iframe this error was coming 

Hi All,

 

I have a trigger that creates a task for a set of criteria on a custom object called Implementation. Whenever a non system admin user enters in the Target Go Live Date on the implementation record, the Trainer listed on the Implementation record will have a task created for them. Currently, whenever this trigger fires for the after update portion, it creates two duplicate tasks. I've crawled through several debug logs and toggled things on and off and found that if I turn off one specific workflow rule, the duplication does not occur. 

 

Any thoughts or ideas on why this particular workflow is causing the trigger to run twice?

 

Here's the workflow: (updates the Target Go Live Month field when the Target Go Live Date field is changed)

- Evaluate the rule when a record is created, and every time it's edited

- Object: Implementation

ISCHANGED( Target_Go_Live_Date__c)

- Field update:

- Field to update: Implementation: Target Go Live Month

CASE( TEXT( MONTH( Target_Go_Live_Date__c)), 
"1", "01 - Jan", 
"2", "02 - Feb", 
"3", "03 - Mar", 
"4", "04 - Apr", 
"5", "05 - May", 
"6", "06 - Jun", 
"7", "07 - Jul", 
"8", "08 - Aug", 
"9", "09 - Sep", 
"10", "10 - Oct", 
"11", "11 - Nov", 
"12", "12 - Dec", 
"")

 

Here's the trigger:

trigger TargetGoLiveDateTrainerTask on Implementation_del__c (after insert, after update) {
  List<Task> tasks = new List<Task>();
  Id currentUserProfileId = UserInfo.getProfileId();
  Set<Id> implementationIds = new Set<Id>();
  Date taskDate = System.today();
  RecordType recordType = RecordTypeResolver.find('Task', 'Client Services');
  
  //Exclude all System Admins from creating this task
  if (new Set<Id> {'00e30000000dSKN'}.contains(currentUserProfileId))
    return;

  for (Integer i = 0; i < Trigger.size; i++) {

    if ((Trigger.isInsert || Trigger.old[i].Target_Go_Live_Date__c == null) &&
      (Trigger.new[i].Target_Go_Live_Date__c != null &&
       Trigger.new[i].Training_Required__c != 'No'))
        
      implementationIds.add(Trigger.new[i].Id);
  }
  
  if( implementationIds != null) {

    List<Implementation_del__c> implementations = new List<Implementation_del__c>([SELECT Id, Account__c, Trainer__c, Account__r.Name, Target_Go_Live_Date__c FROM Implementation_del__c WHERE Id IN :implementationIds]);
  
    for (Implementation_del__c implementation : implementations) {

      if (implementation.Trainer__c == null) {
        implementation.addError('Implementation has no Trainer set.  Please set a Trainer for the \'Training Kick Off Call\' Task to continue.  Contact an administrator for more information.');
      }

      else if (System.today().daysBetween(implementation.Target_Go_Live_Date__c) < 30) {
        tasks.add( new Task( Subject = 'Training Kick Off Call: ' + (implementation.Account__c != null ? implementation.Account__r.Name : '<Unknown>'),
                  OwnerId = implementation.Trainer__c,
                  ActivityDate = taskDate,
                   ReminderDateTime = System.today(),
                  IsReminderSet = True,
                  WhatId = implementation.Id,
                  RecordTypeId = recordType.Id ));
      }
      
      else {
        taskDate = implementation.Target_Go_Live_Date__c - 30;
        tasks.add( new Task( Subject = 'Training Kick Off Call: ' + (implementation.Account__c != null ? implementation.Account__r.Name : '<Unknown>'),
                 OwnerId = implementation.Trainer__c,
                 ActivityDate = taskDate,
                 ReminderDateTime = DateTime.newInstance(taskDate, Time.newInstance(8, 0, 0, 0)),
                 IsReminderSet = True,
                 WhatId = implementation.Id,
                 RecordTypeId = recordType.Id ));
      }
    }
    
    if(tasks != null)
      insert tasks;
  }