• Maciej Gunia
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies

Hello,

 

I am trying to create a javascript button which will first update a field in the Campaign Member level and then open the page of the new opportunity wizard. I found on the internet the code whcih I used to amend. However, the code returns the error about unexpected identifier:

 

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}

var c = new sforce.SObject("CampaignMember");
c.id = "{!CampaignMember.Id}";
c.Proposal_Sent__c = true;
result = sforce.connection.update([c]);

window.location.reload();

 

Could any of you help me what should be changed in this code to make it work. I expect CampaignMember brings here the confusion and probably it should be coded differently.

Hello,

 

I am very new to that forum, so at the beginning I want to say "hello" to everyone!

 

I am new to APEX and I face the problem which APEX trigger seems to be a solution. I would need a trigger in Salesforce which would update the field located in Users object (standard object) using the value from Holidays Remaining field from Staff object (custom object). In other words, what is populated in Holidays Remaining in Staff it should be copied to the field called holidays Remaining in the Users level. Could anyone help me with that please?

Hello, 

 

I installed "Inline Account Hierarchy" and it looks great. However, I am wondering if there is a chance to use this while building reports. For instance to build the summary account report which will show me all accounts who are parent accounts and thier child companies. Is it possible to modify Inline Account Hierarchy somehow to make it possible?

 

Regards,

Maciej

I have a trigger which works in the sandbox. The workflow checks the field in the campaign level and compares it with the custom setting. If it matches, then it returns the target to the DS Multiplier field. The trigger looks as follows

trigger PopulateTarget on Campaign (before insert, before update) 
{
for(Campaign campaign : Trigger.new)
{
    if (String.isNotBlank(campaign.Apex_Calculator__c) == true)
    {
        DSTargets__c targetInstance = DSTargets__c.getInstance(campaign.Apex_Calculator__c);
        {
            String target = targetInstance .Target__c;
             campaign.DS_Target_Multiplier__c = Target;
        }
    }
}
}

However, I had problems to write a proper test to this and asked for the help on the internet. I received the test

@isTest
private class testPopulateTarget{
static testMethod void testMethod1(){

      // Load the Custom Settings
      DSTargets__c testSetting = new DSTargets__c(Name='Africa - 10 Weeks; CW 10',Target__c='0.1538', SetupOwnerId = apexCalculatorUserId);
      insert testSetting;


       // Create Campaign. Since it would execute trigger, put it in start and stoptests
       Test.startTest();
           Campaign testCamp = new Campaign();
           // populate all reqd. fields.
           testCamp.Name = 'test DS campaign';
           testCamp.RecordTypeId = '012200000001b3v';
           testCamp.Started_Campaign_weeks_before_Event__c = '12 Weeks';
           testCamp.ParentId= '701g0000000EZRk';


           insert testCamp;
       Test.stopTest();
       testCamp = [Select ID,Apex_Calculator__c,DS_Target_Multiplier__c from Campaign where Id = :testCamp.Id];
       system.assertEquals(testCamp.DS_Target_Multiplier__c,testSetting.Target__c);// assert that target is populated right

}

}

Such test returns the error "Compile Error: Variable does not exist: apexCalculatorUserId at line 6 column 122". If I remove that ApexCalculator part System.assertEquals then the test passes. However it covers 4/6 part of the code (which is 66%). 

As I was able to find out that apexCalculatorUserId has not been defined. I was suggested to look at the constructor DSTargets__c and see what kind of ID it is expecting there. However, my knowledge doesn't allow me to amend it this way it will work. Would any of you help me to amend it as it seems I am on the last corner before the finish line and am hopeless with this test?

Regards,
Maciej

Hello,

 

I am very new to that forum, so at the beginning I want to say "hello" to everyone!

 

I am new to APEX and I face the problem which APEX trigger seems to be a solution. I would need a trigger in Salesforce which would update the field located in Users object (standard object) using the value from Holidays Remaining field from Staff object (custom object). In other words, what is populated in Holidays Remaining in Staff it should be copied to the field called holidays Remaining in the Users level. Could anyone help me with that please?