• Philip Nelson
  • NEWBIE
  • 100 Points
  • Member since 2014
  • Director of Engineering
  • roundCorner


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 16
    Replies
Hello there,

I am trying to create a backup of all my metadata from the Full Sandbox. I have 3 orgs I'm working with
1. A Production Org
2. A Full Sandbox (which I need to refresh)
3. A Developer Pro Sandbox (which I just created). I'm assuming this is a metadata copy of Production

I am planning to download my critical metadata from the Full sandbox using the Force.com IDE - I already have the classes, pages, triggers, components, and will also download the custom objects that I need. 

I have one question: if I refresh my Full Sandbox, will that also refresh the Developer Pro Sandbox?  

 
I have been trying to use the new Visualforce Object for some basic javascript functions, but have a tough time using a retrieve with a date clause.

example sniplet :
var c = new SObjectModel.Campaign(); c.retrieve(function(){return({ limit : 100, where: {StartDate: { gt: '2014-12-31' }}});}, function (err, records) { if (err) { console.log(err); } else {


I have formatted the date in miliseconds, utc string (2014-12-31T23:59:59Z), and a few others. So far always get ther error:
"Error: Error occurred while performing RETRIEVE operation on sobject: Campaign with data: {limit=100, where={StartDate={gt=2014-12-31}}} (INVALID_FIELD: type, id FROM Campaign WHERE StartDate > '2014-12-31' LIMIT 100 ^ ERROR at Row:1:Column:81 value of filter criterion for field 'StartDate' must be of type date and should not be enclosed in quotes)"

I have tried it for other objects that have DateTime formats ( ie CreatedDate ) wit the same problems.
Has anyone solved this? Maybe us moment.js to set a specific format?

Thanks for your help!
 

I was just trying to understand wrapper classes and then happen to see the below code. Understood everything almost but one thing I am not able to understand is; if I select one or two Account records by clicking on the checkbox (and not all account records through the topmost checkbox), then how the value of the Boolean variable "Selected" is becoming True from false for the selected account records?

See the below Visualforce code and controller class:
-----------VF------------------------------
<apex:page controller="wrapperControllerClassExample1" sidebar="false">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
 
                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.BillingState}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                    <apex:column value="{!c.BillingState}" headerValue="Billing State"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>

------------Controller-----------------
public class wrapperControllerClassExample1 {
 
    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
 
    public wrapperControllerClassExample1(){
        if(wrapAccountList == null) {
            wrapAccountList = new List<wrapAccount>();
            for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapAccountList.add(new wrapAccount(a));
            }
        }
    }
 
    public void processSelected() {
    selectedAccounts = new List<Account>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList) {
            if(wrapAccountObj.selected == true) {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
    }
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapAccount {
        public Account acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Account a) {
            acc = a;
            selected = false;
        }
    }
}

 

UGH Admin with Validation Rule nesting problems :-/   In summary, this rule is specific to users in the FL market, when a Tour_Status__c = any of our completed stages, either Tour_Completed_By_Sales_User__c (user lookup) OR Tour_Completed_By_Operations__c (CHECKBOX) must be populated.  The error is throwing properly on the Sales User field but it is also erroring when I turn the Operations User Checkbox True.  Any advice? 

AND((CreatedBy.Division ="Florida"),
(ISPICKVAL(Tour_Status__c, "Tour Completed - NPA")||
ISPICKVAL(Tour_Status__c, "Tour Completed - Requests follow up call")||
ISPICKVAL(Tour_Status__c, "Tour Completed - Wants to think about it")||
ISPICKVAL(Tour_Status__c, "Tour Completed - Declined")),
((ISBLANK(Tour_Completed_By_Sales_User__c)|| Tour_Completed_By_Operations__c
)))
I have the trigger class below and I would like it to fire nly when an Opportunity Stage is changed to Closed Won. Can anyone helpme figure out how to do this? I have an If statement, but it fires any time an Opportunity that is Closed Won is edited, and when I tried to add another condition it gives me the error message: Error: Compile Error: Field expression not allowed for generic SObject at line 12 column 85. I only want it to fire when the Stage is initially changed. Thanks.

Trigger:
trigger MainTriggerOpportunity on Opportunity (after update) {

            ClassRenewalOppClone updater13 = new ClassRenewalOppClone();
            updater13.cloneOpp(Trigger.new);

}

Trigger Class:
public class ClassRenewalOppClone {

    public void cloneOpp(List<Opportunity> cloneOpp){

    String recordTypeName = 'Renewals';
    Map<String,Schema.RecordTypeInfo> rtMapByName = Schema.SObjectType.Opportunity.getRecordTypeInfosByName();
    Schema.RecordTypeInfo rtInfo =  rtMapByName.get(recordTypeName);
    id recType = rtInfo.getRecordTypeId();


        FOR(Opportunity opp1 : cloneOpp){
            IF(opp1.StageName.contains('Closed Won') && trigger.OldMap.get(opp1.Id).isclosed == false && opp1.RecordTypeId == recType){

            String OppId = opp1.Id;

            //Clone the Opportunity that is associated with the handoff and all createable fields 
                /* query Opportunity and then clone it */
                String soql = RecClone.getCreatableFieldsSOQL('Opportunity','Id =: OppId');
                    Opportunity opp = (Opportunity)Database.query(soql);
                    Opportunity opp2 = opp.clone(false, true);
                insert opp2;

                List<OpportunityLineItem> itemList = (List<OpportunityLineItem>)Database.query(RecClone.getCreatableFieldsSOQL('OpportunityLineItem','OpportunityId =: OppId'));

                List<OpportunityLineItem> newItemList = new List<OpportunityLineItem>();

                    for (OpportunityLineItem item : itemList) {
                        OpportunityLineItem ol = item.clone(false, true);
                            ol.totalprice = null;
                            ol.opportunityid = opp2.id;
                        newItemList.add(ol);
                    }
                insert newItemList;
            }
            }
        }
}

 
Hello there,

I am trying to create a backup of all my metadata from the Full Sandbox. I have 3 orgs I'm working with
1. A Production Org
2. A Full Sandbox (which I need to refresh)
3. A Developer Pro Sandbox (which I just created). I'm assuming this is a metadata copy of Production

I am planning to download my critical metadata from the Full sandbox using the Force.com IDE - I already have the classes, pages, triggers, components, and will also download the custom objects that I need. 

I have one question: if I refresh my Full Sandbox, will that also refresh the Developer Pro Sandbox?  

 
Hi All,

May i know that Why i am getting following Error while i am updating Record?
But in Debug logs i am getting values that what i want to update. Could you please change my trigger.


Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger editGenerateLogbooks caused an unexpected exception, contact your administrator: editGenerateLogbooks: execution of AfterUpdate caused by: System.ListException: Duplicate id in list: a04f0000005HAXyAAO: Trigger.editGenerateLogbooks: line 68, column 1
 
trigger editGenerateLogbooks on Log_Book__c (after update) {
    
    Set<id> set1 = new Set<id>();
    Set<String> weeks = new Set<String>(); 
    Set<String> subjects = new Set<String>();
    Set<String> students = new Set<String>();   
    List<Weeks__c> weekList = Weeks__c.getAll().values();
    List<Log_Book__c> lb = new List<Log_Book__c>();
    List<Log_Book__c> lbDelList = new List<Log_Book__c>();
    List<Log_Book__c> lstToUpdate = new List<Log_Book__c>();
    Map<Integer,weeks__c> weekMap = new Map<Integer,weeks__c>();
   
    
    for(weeks__c week : weekList)
    {
        weekMap.put((Integer)week.Order__c,week);
         
    }
    for(Log_Book__c lbook : Trigger.old)
    {
        set1.add(lbook.Id);
    }
    lb=[select Abacus__c, Absent_Time_Stamp__c, Absent__c, Attended__c, Class_Scheduled_Date__c, Collected_Book__c, Comments__c, Do_Not_Promote__c, English__c, Level__c, Order__c, Reason__c, Id, Student__c, Subject__c, Subjects_Registered__c, Week__c, Week_Day__c, gk__c, math__c from log_book__c where id in: set1];
    for(Log_Book__c lbdelete : lb)
    {
        if(lbdelete.Class_Scheduled_Date__c >= System.today())
        {
            lbDelList.add(lbdelete);
           
        }
    }
    for(Log_Book__c lbUpdate : Trigger.new)
    {
        
    
            weeks.add(lbUpdate.week__c);
            subjects.add(lbUpdate.Subject__c);
            students.add(lbUpdate.Student__c); 
   
    }
    
      for(Log_Book__c lbup : [select Abacus__c, Absent_Time_Stamp__c, Absent__c, Attended__c, Class_Scheduled_Date__c, Collected_Book__c, Comments__c, Do_Not_Promote__c, English__c, Level__c, Order__c, Reason__c, Id, Student__c, Subject__c, Subjects_Registered__c, Week__c, Week_Day__c, gk__c, math__c from log_book__c where subject__c IN: subjects AND Student__c IN: students AND week__c IN: weeks AND Class_Scheduled_Date__c >=: system.today() order by order__c])
      {
      
          String[] weekLevels = lbup.Week__c.split('-');
          Integer weekLevel = Integer.valueof(weekLevels[0]);
   
       if(lbup.week__c != Trigger.oldMap.get(lbup.id).week__c || lbup.Class_Scheduled_Date__c >= System.Today())
       {
           for(Integer j=weekLevel;j<27;j++)
           {
            system.debug('++hiiiiiiiiiii+');
            lbup.Class_Scheduled_Date__c = lbup.Class_Scheduled_Date__c.addDays(7);
            lbup.week__c = weekMap.get(weekLevel).name;
            system.debug('*****Jagadeesh********'+lbup.Class_Scheduled_Date__c + lbup.Level__c + lbup.Week__c);
            lstToUpdate.add(lbup);
            
            weekLevel++;
            
            }
            weekLevel = 1;
        }
      }
    
   
    
    delete lbDelList;
    update lstToUpdate;
}

User-added image
Lightning is advertised as a modular system to quickly build apps by combining pre-built components, but every single demo or webinar I've watched starts from scratch.  Where can I find pre-built copmonents?
  • February 15, 2015
  • Like
  • 0
I have been trying to use the new Visualforce Object for some basic javascript functions, but have a tough time using a retrieve with a date clause.

example sniplet :
var c = new SObjectModel.Campaign(); c.retrieve(function(){return({ limit : 100, where: {StartDate: { gt: '2014-12-31' }}});}, function (err, records) { if (err) { console.log(err); } else {


I have formatted the date in miliseconds, utc string (2014-12-31T23:59:59Z), and a few others. So far always get ther error:
"Error: Error occurred while performing RETRIEVE operation on sobject: Campaign with data: {limit=100, where={StartDate={gt=2014-12-31}}} (INVALID_FIELD: type, id FROM Campaign WHERE StartDate &gt; '2014-12-31' LIMIT 100 ^ ERROR at Row:1:Column:81 value of filter criterion for field 'StartDate' must be of type date and should not be enclosed in quotes)"

I have tried it for other objects that have DateTime formats ( ie CreatedDate ) wit the same problems.
Has anyone solved this? Maybe us moment.js to set a specific format?

Thanks for your help!
 

I was just trying to understand wrapper classes and then happen to see the below code. Understood everything almost but one thing I am not able to understand is; if I select one or two Account records by clicking on the checkbox (and not all account records through the topmost checkbox), then how the value of the Boolean variable "Selected" is becoming True from false for the selected account records?

See the below Visualforce code and controller class:
-----------VF------------------------------
<apex:page controller="wrapperControllerClassExample1" sidebar="false">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
 
                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.BillingState}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                    <apex:column value="{!c.BillingState}" headerValue="Billing State"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>

------------Controller-----------------
public class wrapperControllerClassExample1 {
 
    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
 
    public wrapperControllerClassExample1(){
        if(wrapAccountList == null) {
            wrapAccountList = new List<wrapAccount>();
            for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapAccountList.add(new wrapAccount(a));
            }
        }
    }
 
    public void processSelected() {
    selectedAccounts = new List<Account>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList) {
            if(wrapAccountObj.selected == true) {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
    }
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapAccount {
        public Account acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Account a) {
            acc = a;
            selected = false;
        }
    }
}