• Integration 39
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
Hello,
We have a number of servers that come and go that need access to the bulk API.

To give them access their IP has to be added to the trusted IPs in network access.

Is there any way to add and remove IPs from that list using any built in APIs?
Hello,
I am having trouble hitting the code coverage level on a event trigger, i am getting 57% at the moment.

I am guessing there is something small i am missing.

Any hits would be great.

===== Trigger =====
trigger CreateReminder on Enrolment__c (after insert) {
    List<Enrolment__c> Enrolment = new List<Enrolment__c>();
    List<Event> tasks = new List<Event>();  
    
    for (Enrolment__c e: trigger.new) {
        Product2[] PD = [select Agent_Reminder__c,Enrolment_Support_Reminder__c from Product2 where Id = :e.Product__c and IsActive = TRUE];
        Group GP = [SELECT Id FROM Group where Name = 'Enrolment Support Reminders'];
        GroupMember GM = [SELECT UserOrGroupId FROM GroupMember where GroupId = :GP.id limit 1];
        String enrolment_support = GM.UserOrGroupId;
        
        for(Product2 ipd: PD ) {
       
            if (ipd.Agent_Reminder__c == true) {
                tasks.add(new Event(
                    Whatid = e.id,  
                    OwnerID = UserInfo.getUserId(),
                    Engagement__c = 'Follow Up Pending ',
                    Subject = '48 hour enrolment follow-up call',
                    Description = 'Please call your enrolled student and ensure they have successfully submitted all relevant documentation and have accepted their offer.\n\nPlease ensure they are happy with the process so far, and overcome any issues they may have.\n\nPlease send Lode Careers email and encourage the student to opt-in now.',
                    ReminderDateTime = System.now().addHours(47),
                    IsReminderSet = true,
                    DurationInMinutes = 5,
                    StartDateTime = System.now().addHours(48)
                    )
                );
            }
            
            if (ipd.Enrolment_Support_Reminder__c == true) {
                tasks.add(new Event(
                    Whatid = e.id,
                    OwnerID = enrolment_support,
                    Engagement__c = 'Follow Up Pending ',
                    Subject = 'Enrolment Support: Follow-up enrolment',
                    Description = 'Please validate this enrolment is progressing towards the first census date.',
                    DurationInMinutes = 5,
                    StartDateTime = System.now().addHours(336)
                    )
                );
            }
        }
    }  
    
    insert tasks;
}


===== Test Class =====
@isTest
private class test_create_reminder {

    @isTest(SeeAllData=false)
    private static void test_create_enrolment() {
    
        List<enrolment__c> createenrolment = new List <enrolment__c> ();
        
        List<Account> acc = [SELECT id FROM account limit 1];
        
        for (Account a: acc) {
            createenrolment.add(
                new enrolment__c(
                    Product__c = '01t90000004q3PH',
                    Account__c = a.id,
                    Call_Centre__c = 'Call_Centre__c',
                    Who_Enrolled__c = '00590000001Symm'
                )
            );
        }
        
        insert createenrolment;

    
        List<Event> tasks = new List<Event>();
        List<Enrolment__c> en = [SELECT id FROM Enrolment__c limit 1];

        for (Enrolment__c e: en) {
            Product2[] PD = [select Agent_Reminder__c,Enrolment_Support_Reminder__c from Product2 where Id = :e.Product__c];
            Group GP = [SELECT Id FROM Group where Name = 'Enrolment Support Reminders'];
            GroupMember GM = [SELECT UserOrGroupId FROM GroupMember where GroupId = :GP.id limit 1];
            String enrolment_support = GM.UserOrGroupId;
                
            for(Product2 ipd: PD ) {
                if (ipd.Agent_Reminder__c == true) {
                    tasks.add(new Event(
                            Whatid = e.id,  
                            OwnerID = UserInfo.getUserId(),
                            Engagement__c = 'Follow Up Pending ',
                            Subject = '48 hour enrolment follow-up call',
                            Description = 'Please call your enrolled student and ensure they have successfully submitted all relevant documentation and have accepted their offer.\n\nPlease ensure they are happy with the process so far, and overcome any issues they may have.\n\nPlease send Lode Careers email and encourage the student to opt-in now.',
                            ReminderDateTime = System.now().addHours(47),
                            IsReminderSet = true,
                            DurationInMinutes = 5,
                            StartDateTime = System.now().addHours(48)
                            )
                    );
                }

                if (ipd.Enrolment_Support_Reminder__c == true) {
                    tasks.add(new Event(
                        Whatid = e.id,
                        OwnerID = enrolment_support,
                        Engagement__c = 'Follow Up Pending ',
                        Subject = 'Enrolment Support: Follow-up enrolment',
                        Description = 'Please validate this enrolment is progressing towards the first census date.',
                        DurationInMinutes = 5,
                        StartDateTime = System.now().addHours(336)
                        )
                    );  
                }
            }   
            
            insert tasks;
        }
    }
}
Hello,
I am trying to create an email template with data from the product accociated to the opportunity.

When i use the product varabiles i get null data returned.

I updated a trigger to write to the opportunity line item to grab the information i needed but that is also null.

It is not possible to get a trigger to update the opportunity as it is locked when triggered.

Does anyone have any suggestions to get around this?
Hello,
I am getting 71% code coverage. I have to be missing something really simple.

I have posted my test plan and trigger below.

Please let me know if you have any questions.

I would appreciate any help.

== Test Plan ==
@isTest(SeeAllData=false)
private class TestCreateOppTeam{

    @isTest(SeeAllData=false)
    private static void TestCreateOppTeam() {

        Opportunity opp = new Opportunity(Name='Test opp', StageName='stage', Probability = 10, CloseDate=system.today(), Campaign_Medium__c = 'Campaign_Medium__c',Campaign_Name__c = 'Campaign_Name__c',Product__c = '01t90000004q3PH',Call_Centre__c = 'Call_Centre__c');     
        insert opp;
        
        Opportunity [] OL = [select Id from Opportunity where Id = :opp.id];
        
        for (Opportunity o: OL ) {
            UserRole rn=[Select Name from UserRole where Id= :UserInfo.getUserRoleId()];
            String Role = rn.name;
        
            OpportunityTeamMember newTeamMember = new OpportunityTeamMember();
            newTeamMember.OpportunityId = o.id;
            newTeamMember.UserId = UserInfo.getUserId();
        
            if (role != 'Admin') {
                if (role.containsIgnoreCase('TEST WORD')) {
                    newTeamMember.TeamMemberRole = 'Role 1';
                } else {
                    newTeamMember.TeamMemberRole = 'Role 2';
                }
                insert newTeamMember;
            }
        }
    }
}

== Trigger ==
trigger CreateOppTeam on Opportunity (after insert) {
    
    for (Opportunity o: trigger.new) {
        UserRole rn=[Select Name from UserRole where Id= :UserInfo.getUserRoleId()];
        String Role = rn.name;
        
        OpportunityTeamMember newTeamMember = new OpportunityTeamMember();
        newTeamMember.OpportunityId = o.id;
        newTeamMember.UserId = UserInfo.getUserId();
        
        if (role != 'Admin') {
            if (role.containsIgnoreCase('TEST WORD')) {
                newTeamMember.TeamMemberRole = 'Role 1';
            } else {
                newTeamMember.TeamMemberRole = 'Role 2';
            }
        
            insert newTeamMember;
        }
    }
}
Hello,
I have got a trigger the insert into custom object when opportunity is won.

The problem i am having is if someone update the opportunity after it is won another record is inserted into the custom object.

To avoid this i tried adding a custom field to specify if this is the first time it has been updated when the opportunity has been won.

I am getting a front end error saying the opportunity is readonly, how can i fix this?

trigger CreateEnrolment on Opportunity (After update) {

    List<enrolment__c> createenrolment = new List <enrolment__c> ();
    
    for (Opportunity o: trigger.new) {
            if (o.isWon == true && o.converted_2_enrolment__c == FALSE) {
                    createenrolment.add(
                    new enrolment__c(
                    Campaign_Medium__c = o.Campaign_Medium__c,
                    Campaign_Name__c = o.Campaign_Name__c,
                    Product__c = o.Product__c,
                    Opportunity__c = o.id,
                    Account__c = o.AccountId,
                    Call_Centre__c = o.Call_Centre__c,
                    Who_Enrolled__c = UserInfo.getUserId()));
                    
                    o.converted_2_enrolment__c = TRUE;
                    update o;
            }
    }

    try {
        insert createenrolment;
    }
    catch (Exception Ex){
        system.debug(Ex);
    }
}
 
Hello,
I am trying to write a simple trigger. It has been tested in the sandbox and all looks good.

I have put the trigger and test below. Both are in the change set.

What am i doing wrong?

Trigger
trigger CreateEnrolment on Opportunity (after insert, after update) {
List<enrolment__c> createenrolment = new List <enrolment__c> ();
    
for (Opportunity o: trigger.new) {
if (o.isWon == true) {
createenrolment.add(
new enrolment__c(
Campaign_Medium__c = o.Campaign_Medium__c,
Campaign_Name__c = o.Campaign_Name__c,
Product__c = o.Product__c,
Opportunity__c = o.id,
Account__c = o.AccountId,
Call_Centre__c = o.Call_Centre__c,
Who_Enrolled__c = UserInfo.getUserId()));
}
}
 
try {
insert createenrolment;
}
catch (Exception Ex){
system.debug(Ex);
}
}

Test
@isTest(SeeAllData=false)
private class Testcreateenrolment{
 
 
@isTest(SeeAllData=false)
private static void Testcreateenrolment() {
 
List<enrolment__c> createenrolment = new List <enrolment__c> ();
 
createenrolment.add(
new enrolment__c(
Campaign_Medium__c = 'Campaign_Medium__c',
Campaign_Name__c = 'Campaign_Name__c',
Product__c = '01t90000004q3PH',
Account__c = '00190000014B4x7',
Call_Centre__c = 'Call_Centre__c',
Who_Enrolled__c = '00590000001Symm'));
 
try {
insert createenrolment;
}
catch (Exception Ex){
system.debug(Ex);
}
}
}
 
Hello,
I am getting 71% code coverage. I have to be missing something really simple.

I have posted my test plan and trigger below.

Please let me know if you have any questions.

I would appreciate any help.

== Test Plan ==
@isTest(SeeAllData=false)
private class TestCreateOppTeam{

    @isTest(SeeAllData=false)
    private static void TestCreateOppTeam() {

        Opportunity opp = new Opportunity(Name='Test opp', StageName='stage', Probability = 10, CloseDate=system.today(), Campaign_Medium__c = 'Campaign_Medium__c',Campaign_Name__c = 'Campaign_Name__c',Product__c = '01t90000004q3PH',Call_Centre__c = 'Call_Centre__c');     
        insert opp;
        
        Opportunity [] OL = [select Id from Opportunity where Id = :opp.id];
        
        for (Opportunity o: OL ) {
            UserRole rn=[Select Name from UserRole where Id= :UserInfo.getUserRoleId()];
            String Role = rn.name;
        
            OpportunityTeamMember newTeamMember = new OpportunityTeamMember();
            newTeamMember.OpportunityId = o.id;
            newTeamMember.UserId = UserInfo.getUserId();
        
            if (role != 'Admin') {
                if (role.containsIgnoreCase('TEST WORD')) {
                    newTeamMember.TeamMemberRole = 'Role 1';
                } else {
                    newTeamMember.TeamMemberRole = 'Role 2';
                }
                insert newTeamMember;
            }
        }
    }
}

== Trigger ==
trigger CreateOppTeam on Opportunity (after insert) {
    
    for (Opportunity o: trigger.new) {
        UserRole rn=[Select Name from UserRole where Id= :UserInfo.getUserRoleId()];
        String Role = rn.name;
        
        OpportunityTeamMember newTeamMember = new OpportunityTeamMember();
        newTeamMember.OpportunityId = o.id;
        newTeamMember.UserId = UserInfo.getUserId();
        
        if (role != 'Admin') {
            if (role.containsIgnoreCase('TEST WORD')) {
                newTeamMember.TeamMemberRole = 'Role 1';
            } else {
                newTeamMember.TeamMemberRole = 'Role 2';
            }
        
            insert newTeamMember;
        }
    }
}
Hi
I have requirement that i need a user object related list in another custom object Please any body suggest me .

or 
 I need a custom lookup were we can select multiple users with single lookup.......


Please very urgent


Thanks
 
Hello,
I have got a trigger the insert into custom object when opportunity is won.

The problem i am having is if someone update the opportunity after it is won another record is inserted into the custom object.

To avoid this i tried adding a custom field to specify if this is the first time it has been updated when the opportunity has been won.

I am getting a front end error saying the opportunity is readonly, how can i fix this?

trigger CreateEnrolment on Opportunity (After update) {

    List<enrolment__c> createenrolment = new List <enrolment__c> ();
    
    for (Opportunity o: trigger.new) {
            if (o.isWon == true && o.converted_2_enrolment__c == FALSE) {
                    createenrolment.add(
                    new enrolment__c(
                    Campaign_Medium__c = o.Campaign_Medium__c,
                    Campaign_Name__c = o.Campaign_Name__c,
                    Product__c = o.Product__c,
                    Opportunity__c = o.id,
                    Account__c = o.AccountId,
                    Call_Centre__c = o.Call_Centre__c,
                    Who_Enrolled__c = UserInfo.getUserId()));
                    
                    o.converted_2_enrolment__c = TRUE;
                    update o;
            }
    }

    try {
        insert createenrolment;
    }
    catch (Exception Ex){
        system.debug(Ex);
    }
}
 
Hello,
I am trying to write a simple trigger. It has been tested in the sandbox and all looks good.

I have put the trigger and test below. Both are in the change set.

What am i doing wrong?

Trigger
trigger CreateEnrolment on Opportunity (after insert, after update) {
List<enrolment__c> createenrolment = new List <enrolment__c> ();
    
for (Opportunity o: trigger.new) {
if (o.isWon == true) {
createenrolment.add(
new enrolment__c(
Campaign_Medium__c = o.Campaign_Medium__c,
Campaign_Name__c = o.Campaign_Name__c,
Product__c = o.Product__c,
Opportunity__c = o.id,
Account__c = o.AccountId,
Call_Centre__c = o.Call_Centre__c,
Who_Enrolled__c = UserInfo.getUserId()));
}
}
 
try {
insert createenrolment;
}
catch (Exception Ex){
system.debug(Ex);
}
}

Test
@isTest(SeeAllData=false)
private class Testcreateenrolment{
 
 
@isTest(SeeAllData=false)
private static void Testcreateenrolment() {
 
List<enrolment__c> createenrolment = new List <enrolment__c> ();
 
createenrolment.add(
new enrolment__c(
Campaign_Medium__c = 'Campaign_Medium__c',
Campaign_Name__c = 'Campaign_Name__c',
Product__c = '01t90000004q3PH',
Account__c = '00190000014B4x7',
Call_Centre__c = 'Call_Centre__c',
Who_Enrolled__c = '00590000001Symm'));
 
try {
insert createenrolment;
}
catch (Exception Ex){
system.debug(Ex);
}
}
}