• Miller 95
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
Hi Everyone,

Not sure if I am doing this right. I would like to get your opinion. I am looking to use the batch schedule to go out and look at all my active campaigns that have a end date of today and deactivate them. I have tried to use a workflow for this with no success, so this is what I have.

global class DeactivateCampaignBatch implements Database.Batchable<sObject>{

   //Start Method
   global Database.QueryLocator start(Database.BatchableContext BC){ 
       String Query = 'SELECT EndDate FROM Campaign WHERE Campaign.EndDate=Today()';
       return Database.getQueryLocator(query);
   }

   //Execute Logic
   global void execute(Database.BatchableContext BC, List<sObject> scope){
    List<Campaign> acamps;
        
        acamps = [SELECT Id
                 FROM Campaign 
                 WHERE IsActive = true
                 limit 100];

   for(sObject s : scope){Campaign c = (Campaign)s;
        if(c.IsActive = true){
            c.IsActive=FALSE;
            acamps.add(c);
            }
        }

    update acamps;
    
   }

   global void finish(Database.BatchableContext BC){
   }
}

I get an error on line 6 saying incorrect token: '('.

Please Help!!!
Hi everyone,

I am trying to build out an email template that will not have me select which related to object because it will be predefined within the html code. I don't want to go in and update the fields by writing in the numbers. I need it to grab the field  based off the specific ID that is predefined within the html code.

This is where I am at:

<messaging:emailTemplate recipientType="Contact"
relatedToType="PricebookEntry"

subject="Stock Listings"

replyTo="me@me.com">
<messaging:htmlEmailBody >
<html>
<body>
<style>
<table>

.xl90
    {mso-style-parent:style16;
    color:windowtext;
    font-size:9.0pt;
    font-family:Arial, sans-serif;
    mso-font-charset:0;
    text-align:center;
    vertical-align:middle;
    border-top:none;
    border-right:1.5pt solid black;
    border-bottom:1.5pt solid black;
    border-left:1.5pt solid black;
    white-space:normal;}
.xl91
    {mso-style-parent:style16;
    color:windowtext;
    font-size:9.0pt;
    font-family:Arial, sans-serif;
    mso-font-charset:0;
    mso-number-format:"\#\,\#\#0_\)\;\\\(\#\,\#\#0\\\)";
    text-align:center;
    vertical-align:middle;
    border-top:none;
    border-right:1.5pt solid black;
    border-bottom:1.5pt solid black;
    border-left:1.5pt solid black;
    white-space:normal;}

</table>
</style>
<tbody>

<tr class="xl65535" style="mso-height-source:userset;height:19.0pt" height="19">
<td colspan="2" class="xl96" style="border-right:1.5pt solid black;height:19.0pt;width:146pt" height="19" width="146">Hard Maple First Grade</td>
        <td class="xl90" style="border-left:none;width:65pt" width="65">3-14'</td>
        <td class="xl91" style="border-left:none;width:51pt" width="51">{!relatedto.000000000m00HaX12T.unitPrice}</td>
        <td class="xl91" style="border-left:none;width:51pt" width="51">{!relatedto.000000000m00AD32gT.unitPrice}</td>
<br />
</td>
</tr>
</tbody>
</table>
</html>
</messaging:htmlEmailBody>
<messaging:plainTextEmailBody >
    
</messaging:plainTextEmailBody>  
</messaging:emailTemplate>

Is this even possible to have mulitple IDs being used within the code and how would I grad specific fields so become a static output?
Hi,

I am creating a Visualforce email template and having a hard time using IDs within the code. My relatedto object is PricebookEntry, as shown:

relatedToType="PricebookEntry"

Within the code I utilize the command {!relatedto.unitprice}. Once I send the email, it then ask me for the PricebookEntryID. I would like to have that ID predefined within the code so users do not have to have that ID on hand. So the code would related to/look something like:

{!relatedto.01uC000000ARO67IAH.unitprice} - I realize this is wrong, but providing an example of what I am explaining.

Any suggestions of how to predefine IDs within Visualforce so users only have to deal with selecting recipients?
Not even sure this is a capability of salesforce, but I thought I would ask the question.

I would like to create an email template of a product list based on individual pricebooks. I am not pulling data from an opportunity, but from the different pricebooks I have available creating stocklist for clients. The data is already in saleforce (uploaded by dataloader through pricebookentry). Since this is a generic stocklist and is not associated to any opportunity. How do I pull that product/price in a list format and is dynamic, so that I am not having to go in and change the email template every time the price changes within the pricebook?

Is this possible or am I limited to static templates?
Hi,

I am new to trigger creation and have mostly built what I wanted which is to have my trigger create a quote automatically once the sales Rep creates the opportunity. The only thing that is missing si to have the trigger also open up that quote that was just created, so the structure would be: Open new Opportunity -> input data -> Click save -> Trigger executes and creates a new quote from that opportunity -> the sales rep lands within the quote ready to select the products (this part is missing.

Not sure if this is possible for a triggers. Here is what I have:

trigger QuoteCreator on Opportunity (after insert, after update) {
Map<Quote, Id> quoteMap = new Map<Quote, Id>();
for (Opportunity o : Trigger.new) {
Quote q = new Quote();
q.name = 'Quote-' + o.name;
q.opportunityId = o.id;
insert q;
quoteMap.put(q, o.accountId);
}
Account[] accList = [SELECT
billingStreet,
billingCity,
billingState,
billingCountry
FROM
Account
WHERE
id IN :quoteMap.values()];
for (Quote quote : quoteMap.KeySet()) {
for (Account a : accList) {
if (quoteMap.get(quote) == a.Id) {
quote.billingStreet = a.billingStreet;
quote.billingCity = a.billingCity;
quote.billingState = a.billingState;
quote.billingCountry = a.billingCountry;
}
update quote;
}
}
}


The second part is creating a test class for it so I can get it moved into production. The Trigger works great within the sandbox, but the testing is needed from what I know about trigger dev into production. Please let me know if I am even doing it right. Here is what I have:

@isTest
private class QuoteCreator {

static testMethod void QuoteCreator() {

    Map<Quote, Id> quoteMap = new Map<Quote, Id>();
       
for (Opportunity o : Trigger.new) {
Quote q = new Quote();
q.name = 'Quote-' + o.name;
q.opportunityId = o.id;
    insert q;
quoteMap.put(q, o.accountId);
    }
   
    test.startTest();

    update quoteMap;

    test.stopTest();
}
}
Hi Everyone,

Not sure if I am doing this right. I would like to get your opinion. I am looking to use the batch schedule to go out and look at all my active campaigns that have a end date of today and deactivate them. I have tried to use a workflow for this with no success, so this is what I have.

global class DeactivateCampaignBatch implements Database.Batchable<sObject>{

   //Start Method
   global Database.QueryLocator start(Database.BatchableContext BC){ 
       String Query = 'SELECT EndDate FROM Campaign WHERE Campaign.EndDate=Today()';
       return Database.getQueryLocator(query);
   }

   //Execute Logic
   global void execute(Database.BatchableContext BC, List<sObject> scope){
    List<Campaign> acamps;
        
        acamps = [SELECT Id
                 FROM Campaign 
                 WHERE IsActive = true
                 limit 100];

   for(sObject s : scope){Campaign c = (Campaign)s;
        if(c.IsActive = true){
            c.IsActive=FALSE;
            acamps.add(c);
            }
        }

    update acamps;
    
   }

   global void finish(Database.BatchableContext BC){
   }
}

I get an error on line 6 saying incorrect token: '('.

Please Help!!!
Not even sure this is a capability of salesforce, but I thought I would ask the question.

I would like to create an email template of a product list based on individual pricebooks. I am not pulling data from an opportunity, but from the different pricebooks I have available creating stocklist for clients. The data is already in saleforce (uploaded by dataloader through pricebookentry). Since this is a generic stocklist and is not associated to any opportunity. How do I pull that product/price in a list format and is dynamic, so that I am not having to go in and change the email template every time the price changes within the pricebook?

Is this possible or am I limited to static templates?
Hi,

I am new to trigger creation and have mostly built what I wanted which is to have my trigger create a quote automatically once the sales Rep creates the opportunity. The only thing that is missing si to have the trigger also open up that quote that was just created, so the structure would be: Open new Opportunity -> input data -> Click save -> Trigger executes and creates a new quote from that opportunity -> the sales rep lands within the quote ready to select the products (this part is missing.

Not sure if this is possible for a triggers. Here is what I have:

trigger QuoteCreator on Opportunity (after insert, after update) {
Map<Quote, Id> quoteMap = new Map<Quote, Id>();
for (Opportunity o : Trigger.new) {
Quote q = new Quote();
q.name = 'Quote-' + o.name;
q.opportunityId = o.id;
insert q;
quoteMap.put(q, o.accountId);
}
Account[] accList = [SELECT
billingStreet,
billingCity,
billingState,
billingCountry
FROM
Account
WHERE
id IN :quoteMap.values()];
for (Quote quote : quoteMap.KeySet()) {
for (Account a : accList) {
if (quoteMap.get(quote) == a.Id) {
quote.billingStreet = a.billingStreet;
quote.billingCity = a.billingCity;
quote.billingState = a.billingState;
quote.billingCountry = a.billingCountry;
}
update quote;
}
}
}


The second part is creating a test class for it so I can get it moved into production. The Trigger works great within the sandbox, but the testing is needed from what I know about trigger dev into production. Please let me know if I am even doing it right. Here is what I have:

@isTest
private class QuoteCreator {

static testMethod void QuoteCreator() {

    Map<Quote, Id> quoteMap = new Map<Quote, Id>();
       
for (Opportunity o : Trigger.new) {
Quote q = new Quote();
q.name = 'Quote-' + o.name;
q.opportunityId = o.id;
    insert q;
quoteMap.put(q, o.accountId);
    }
   
    test.startTest();

    update quoteMap;

    test.stopTest();
}
}