• JSchneider
  • NEWBIE
  • 55 Points
  • Member since 2013
  • Salesforce Administrator
  • Shoptech Software

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 17
    Replies
trigger Sales_Invoice_Custom_Trigger on c2g__codaInvoice__c (before insert, before update) {
    // if this SIN is getting inserted
    if( Trigger.isInsert ) {
        for(c2g__codaInvoice__c SIN : Trigger.new)
        {}
    }
    // if this SIN is getting updated
    if( Trigger.isUpdate ) {
        for(c2g__codaInvoice__c SIN : Trigger.new)
            //check that it has a Sales Order*
            if(SIN.Sales_Order__c != null)
        {
            //get the SIN Outstanding Value
            decimal SINov = SIN.c2g__OutstandingValue__c;
            //query and update the Sales Order*
            Sales_Order__c SalesO = [SELECT Id FROM Sales_Order__c WHERE Id = :SIN.Sales_Order__r].Id;
            SalesO.Outstanding_Value__c = SINov;
        }
    }
}

I am having a problem with the acutal update of the Sales_Order__c record.  Any advice is appreciated, still learning APEX.
This should be easy, but I've got the Salesforce Admin version of writers block.

I am looking to create a headless flow that takes my QuoteLineItems from a Quote and creates new QuoteLineItems in the exact same SortOrder on the exact same quote.  Then I want it to delete the original set of QuoteLineItems.
<apex:dataTable value="{! Quote.QuoteLineItems }" var="line" rowClasses="odd,even" columnClasses="columnBorders" headerClass="dataTableHeader" cellpadding="5px" cellspacing="0" >
<apex:column styleClass="firstColumn" headerValue="Product" value="{! line.Product2.Name }" />
<apex:column headerValue="Description" value="{! line.Description__c }" />
<apex:column styleClass="rightAlignColumn" headerValue="Quantity" value="{! line.Quantity }" />
<apex:column styleClass="rightAlignColumn" headerValue="Unit Price" value="{! line.UnitPrice }" />
<apex:column styleClass="totalsColumn" headerValue="Total Price" value="{! line.TotalPrice }" />
</apex:dataTable>
There is a standard field on QuoteLineItem called SortOrder that I'd like to sort this by.

Any help would be great!
I've several batch jobs that are running smoothly and have no desire to combine the two.  I would like however, when one batch job finishes, for it to call the next batch job.  I assume it goes along the lines of adding database.executeBatch(NextBatchName,BatchSize);  I just cannot figure out where.

This is the exisiting batch class that I'm working with.
global class batchProAssetBuilder implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String myProduct = 'xyz';
        String query = 'SELECT Id,Run_Asset_Builder_Pro__c FROM Account WHERE PIN_Code__c != null AND Product__c = :myProduct';
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext BC, List<Account> scope) {
         for(Account a : scope)
         {
             a.Run_Asset_Builder_Pro__c = true;            
         }
         update scope;
    }   
    
global void finish(Database.BatchableContext BC){

 // Get the AsyncApexJob that represents the Batch job using the Id from the BatchableContext
 AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
  TotalJobItems, CreatedBy.Email, ExtendedStatus
  from AsyncApexJob where Id = :BC.getJobId()];
 
 // Email the Batch Job's submitter that the Job is finished.
 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
 String[] toAddresses = new String[] {a.CreatedBy.Email};
 mail.setToAddresses(toAddresses);
 mail.setSubject('BatchJobXYZ Status: ' + a.Status);
 mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +
  ' batches with '+ a.NumberOfErrors + ' failures. ExtendedStatus: ' + a.ExtendedStatus);
  
 Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}

 
global class batchProAssetBuilder implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String myProduct = 'E2SS 7.2';
        String query = 'SELECT Id,Run_Asset_Builder_Pro__c FROM Account WHERE PIN_Code__c != null AND Product__c = :myProduct';
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext BC, List<Account> scope) {
         for(Account a : scope)
         {
             a.Run_Asset_Builder_Pro__c = true;            
         }
         update scope;
    }   
    
global void finish(Database.BatchableContext BC){

 // Get the AsyncApexJob that represents the Batch job using the Id from the BatchableContext
 AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
  TotalJobItems, CreatedBy.Email, ExtendedStatus
  from AsyncApexJob where Id = :BC.getJobId()];
 
 // Email the Batch Job's submitter that the Job is finished.
 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
 String[] toAddresses = new String[] {a.CreatedBy.Email};
 mail.setToAddresses(toAddresses);
 mail.setSubject('BatchJobXYZ Status: ' + a.Status);
 mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +
  ' batches with '+ a.NumberOfErrors + ' failures. ExtendedStatus: ' + a.ExtendedStatus);
  
 Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
I have a perfectly working OnClick Javascript button already.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
 {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
  var scr="batchMaintenanceCalculator c = new batchMaintenanceCalculator (); " +
         " Database.executeBatch(c, 25); ";
  var result = sforce.apex.executeAnonymous(scr);
   alert("Maintenance amounts are being updated for all customers.");
I am now trying to relocate the button from my Account List View to the Home Page.  I believe the only way moving forward to accomplish this is to have a Visualforce Page with a button that executes the code above.  What would the code end up being on the VF page?
 
I have a very simple command that I plug into the Develope Console and it works great.
batchMaintenanceCalculator b = new batchMaintenanceCalculator();
    database.executeBatch(b,25);
I'ld like to figure out a way that I can create a url that will do the same.  So other users can execute without the Developer Console
 
String query = 'SELECT Id,Run_Maintenance_Calculator_del__c FROM Account WHERE PIN_Code__c != null';

I like to add
AND Custom_Date__c = THIS MONTH
but cannot figure it out.  I appreciate the help. 
|org wide email for sender not supported without a provided email

I have a flow (originating on Case Button Click) firing an email alert (sent from an org wide email) that is causing above error.

any clues?

I am trying to find our deleted and completed tasks using the following query:

 

select id, accountid, subject, result_codes_TASK__c, lastmodifieddate from Task

where isdeleted = true AND isclosed = true AND result_codes_TASK__c <> 'NA' AND result_codes_TASK__c <> 'Action'

order by lastmodifieddate

 

However I am finding that the lastmodifiedbyid and the lastmodifieddate are not the same as the user and date in the recylce bin.

 

I tested it by deleting someone elses completed task, and it still showed their information in the lastmodified fields.

 

Any help here would be much appreciated.

I am trying to have an email sent to me every time an account is changed from a specific status to another status.  The email is currently being sent twice and I can't figure out what I need to fix in the formula.  The idea is that any time an account with a 3 or 4 status changes to anything other than 1-4 or Bad Fit, the emails is generated alerting me.

 

AND(
OR(
ISPICKVAL(PRIORVALUE(Status__c), "3 - Mail Pkt"),
ISPICKVAL(PRIORVALUE(Status__c), "4 - Email Pkt")
)
,
NOT(OR(
ISPICKVAL(Status__c, "Bad Fit"),
ISPICKVAL(Status__c, "1 - Cold"),
ISPICKVAL(Status__c, "2 - Warm"),
ISPICKVAL(Status__c, "3 - Mail Pkt"),
ISPICKVAL(Status__c, "4 - Email - Pkt")
)
)
)

 

The email should show me the user name, account name, city, state, and NEW status.  The first email I get shows the old status, and the second one is correct.

I have a picklist with percentage values of 25, 50, 75, 100.  I have used them in a formula to fill fields by using VALUE(TEXT(Picklist_1__c))/100.

 

What I am trying to accomplish is a sum of that field in a report.  So if Opportunity A has 25, Opp B has 50, Opp C has 100, Opp D has 75; I get a sum of 250 (or 2.5).

 

Please let me know if this can be done or if I have to create another custom field (number) on my Opportunity to store this data and then get SUM that field.

 

Thanks!

trigger Sales_Invoice_Custom_Trigger on c2g__codaInvoice__c (before insert, before update) {
    // if this SIN is getting inserted
    if( Trigger.isInsert ) {
        for(c2g__codaInvoice__c SIN : Trigger.new)
        {}
    }
    // if this SIN is getting updated
    if( Trigger.isUpdate ) {
        for(c2g__codaInvoice__c SIN : Trigger.new)
            //check that it has a Sales Order*
            if(SIN.Sales_Order__c != null)
        {
            //get the SIN Outstanding Value
            decimal SINov = SIN.c2g__OutstandingValue__c;
            //query and update the Sales Order*
            Sales_Order__c SalesO = [SELECT Id FROM Sales_Order__c WHERE Id = :SIN.Sales_Order__r].Id;
            SalesO.Outstanding_Value__c = SINov;
        }
    }
}

I am having a problem with the acutal update of the Sales_Order__c record.  Any advice is appreciated, still learning APEX.
This should be easy, but I've got the Salesforce Admin version of writers block.

I am looking to create a headless flow that takes my QuoteLineItems from a Quote and creates new QuoteLineItems in the exact same SortOrder on the exact same quote.  Then I want it to delete the original set of QuoteLineItems.
<apex:dataTable value="{! Quote.QuoteLineItems }" var="line" rowClasses="odd,even" columnClasses="columnBorders" headerClass="dataTableHeader" cellpadding="5px" cellspacing="0" >
<apex:column styleClass="firstColumn" headerValue="Product" value="{! line.Product2.Name }" />
<apex:column headerValue="Description" value="{! line.Description__c }" />
<apex:column styleClass="rightAlignColumn" headerValue="Quantity" value="{! line.Quantity }" />
<apex:column styleClass="rightAlignColumn" headerValue="Unit Price" value="{! line.UnitPrice }" />
<apex:column styleClass="totalsColumn" headerValue="Total Price" value="{! line.TotalPrice }" />
</apex:dataTable>
There is a standard field on QuoteLineItem called SortOrder that I'd like to sort this by.

Any help would be great!
String query = 'SELECT Id,Run_Maintenance_Calculator_del__c FROM Account WHERE PIN_Code__c != null';

I like to add
AND Custom_Date__c = THIS MONTH
but cannot figure it out.  I appreciate the help. 
|org wide email for sender not supported without a provided email

I have a flow (originating on Case Button Click) firing an email alert (sent from an org wide email) that is causing above error.

any clues?

I am trying to find our deleted and completed tasks using the following query:

 

select id, accountid, subject, result_codes_TASK__c, lastmodifieddate from Task

where isdeleted = true AND isclosed = true AND result_codes_TASK__c <> 'NA' AND result_codes_TASK__c <> 'Action'

order by lastmodifieddate

 

However I am finding that the lastmodifiedbyid and the lastmodifieddate are not the same as the user and date in the recylce bin.

 

I tested it by deleting someone elses completed task, and it still showed their information in the lastmodified fields.

 

Any help here would be much appreciated.

I am trying to have an email sent to me every time an account is changed from a specific status to another status.  The email is currently being sent twice and I can't figure out what I need to fix in the formula.  The idea is that any time an account with a 3 or 4 status changes to anything other than 1-4 or Bad Fit, the emails is generated alerting me.

 

AND(
OR(
ISPICKVAL(PRIORVALUE(Status__c), "3 - Mail Pkt"),
ISPICKVAL(PRIORVALUE(Status__c), "4 - Email Pkt")
)
,
NOT(OR(
ISPICKVAL(Status__c, "Bad Fit"),
ISPICKVAL(Status__c, "1 - Cold"),
ISPICKVAL(Status__c, "2 - Warm"),
ISPICKVAL(Status__c, "3 - Mail Pkt"),
ISPICKVAL(Status__c, "4 - Email - Pkt")
)
)
)

 

The email should show me the user name, account name, city, state, and NEW status.  The first email I get shows the old status, and the second one is correct.

I have a picklist with percentage values of 25, 50, 75, 100.  I have used them in a formula to fill fields by using VALUE(TEXT(Picklist_1__c))/100.

 

What I am trying to accomplish is a sum of that field in a report.  So if Opportunity A has 25, Opp B has 50, Opp C has 100, Opp D has 75; I get a sum of 250 (or 2.5).

 

Please let me know if this can be done or if I have to create another custom field (number) on my Opportunity to store this data and then get SUM that field.

 

Thanks!

Is there any easy way to set some kind of data validation so that fields entered in all caps can be corrected to have only the first letter capitalized?  If this can be done either within a web-to-lead form or when a lead is converted to an account, either would work great.  I haven't found anything yet, though.

 

Thanks!

Just want to get the selected value of a picklist in formula,

 

and I know the CASE() or ISPICKVAL() should be used.

 

But it is terrible if there are mass of option in picklist.

 

I hate to do it like this.

 

 

Anyone can help me?

 

Thanks,

Atlantis