• Mitchell Spano
  • NEWBIE
  • 30 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
Hello All,
We have two custom objects called Financial_Account__c and Household__c with a junction object called household_account__c.
On the household object we have a checkbox field called Is_new_Household__c.
On the Financial Account object we have a date field called Account_Open_Date__c.
I am trying to write a class that checks all financial accounts associated to a household which has been modified within the last day and checks if any of them have an open date which is prior to the household's creation date. If so, the household will not be marked as new.

Here is what I have so far:

global class NewHouseholdBatch implements Database.Batchable<sObject>{
 
     global NewHouseholdBatch(){
                // Batch Constructor
     }
     
     // Start Method
     global Database.QueryLocator start(Database.BatchableContext BC){
         String query = 'SELECT Id, Is_New_Household__c, CreatedDate FROM Household__c WHERE SystemModStamp > :Datetime.now().addDays(-1)'
      return Database.getQueryLocator(query);
     }
    
   // Execute Logic
    global void execute(Database.BatchableContext BC, List<Household__c>scope){
        for (Household__c hh : scope){
            Boolean isnew = true;
            List<Household_Account__c> HouseholdAccounts = [SELECT Household__c.id, Financial_Account__c.id FROM Household_Account__c WHERE Household__c.id = hh.id ];
            for (Household_Account__C hha : HouseholdAccounts ){
                List<Financial_Account__c> FinAccount = [SELECT Account_Open_Date__c, AAC_Account_Status__c FROM Financial_Account__C WHERE Id = hha.Financial_Account__c.id LIMIT 1];
                For (Financial_Account__C fa : FinAccount){
                    if (fa.Account_Open_Date__c < hh.CreatedDate){
                        isnew = false;
                    }
                }
                
            }
            if (isnew==false){
                hh.Is_New_Household__c =false;
            }
        }    
   
    }
   
    global void finish(Database.BatchableContext BC){
         // Logic to be Executed at finish
    }
 }


The developer console keeps saying "unexpected token: 'return' "
I am cofused about this error.
Also, do I need to appent the '.id' to the ennd of the name of the objects in my query on the household account object?

Thank you.
Hello,

I need some help - we are using person acocunts and we have an embedded visualforce page on the account's page layout.
For some reason, when an account's record is open, the UI automatically scrolls to that visualforce page, and I don't know why.

Here is the VF page code - 

<apex:page standardController="Account" extensions="GoalOperations1" id="page">
 
  
 
   <script>
     function ChangeRow1(first , second){
        var size='{!sizeofGoal}';
               
         if(parseInt(size, 10) < parseInt(first, 10) || first==null || first ==0 || parseInt(first, 10)<0 ){
          alert('row number '+first+' does not Exist');
        document.getElementById('page:form:pageblock:table1:'+second+':number').value =parseInt(second, 10)+1;         
          
         }else{
          ChangeRow(first,second);
          }
     
     }
   </script>
 
      <apex:form id="form">
    <apex:variable var="rowNum1" value="{!0}"  />
     <apex:variable var="order" value="{!0}"  />
    <apex:pageMessages id="id1"></apex:pageMessages>
         <apex:outputPanel id="table" >
        <apex:pageBlock title="Financial Concerns" id="pageblock" >
           
          <apex:variable var="rowNum" value="{!0}"  />
            <apex:pageBlockTable value="{!Goals}" var="g" id="table1" width="10%"  >
                    <apex:column headerValue="Order" id="order" width="5%"><apex:inputField onchange="ChangeRow1(document.getElementById('{!$Component.number}').value,'{!rowNum}');"  id="number" style="width:30px;text-align:center;" value="{!g.Order__c}" /> </apex:column>
                  <apex:column headerValue="Tier 1" id="col1" width="10%"> <apex:inputField value="{!g.Level_1_Goals__c}" />  </apex:column>
                  <apex:column headerValue="Tier 2" id="col2" width="10%"><apex:inputField value="{!g.Level_2_Goals__c}"/>  </apex:column>
                  <apex:column headerValue="Description" width="10%" >
                
                    <apex:inputField value="{!g.Comments__c}"  />
                  
                    </apex:column>
                  <apex:column headerValue="Time Frame" id="col4" width="10%"><apex:inputField value="{!g.Time_Frame__c}" />  </apex:column>
                  <apex:column headerValue="Validated Date" id="col6" width="10%"><apex:inputField value="{!g.Validated_Date__c}"  />  </apex:column>
                  <apex:column headerValue="Status" id="col5" width="10%"><apex:inputField value="{!g.Status__c}" />  </apex:column>
                  <apex:column headerValue="Action" width="10%">
                    <apex:commandLink value="Delete" action="{!processDeleted}" reRender="table" >
                           <apex:param value="{!rowNum}" name="index" />
                        </apex:commandLink>
                     <apex:variable var="rowNum" id="rowNum" value="{!rowNum+1}"/>                
                  </apex:column>
                   
            </apex:pageBlockTable>       
            <apex:actionFunction name="ChangeRow" status="status"  action="{!UpdateRow}" rerender="table">
             <apex:param value="" name="first"  > </apex:param>
             <apex:param value=""  name="Second"/>        
            
             </apex:actionFunction>
            
              <apex:outputpanel >
                <apex:actionstatus id="status">
                <apex:facet name="start">
                <div id="el_loading" style="background-color: #fbfbfb;height: 100%;opacity:0.65;width:100%;">
                <div style="top: 74.2px; width: 91px;">
                <img src="/img/loading.gif" title="Please Wait…" />
                <span>Loading…</span>
                </div>
                </div>
                </apex:facet>
                </apex:actionstatus>
             </apex:outputpanel>
           
        </apex:pageBlock>
        </apex:outputPanel>
          <div align="center">
             
              <apex:commandLink value="Save" action="{!SaveAndClose}" target="_parent" styleClass="btn" style="text-decoration:none;padding:4px;"/>
              <!--<apex:commandButton value="Save" action="{!UpsertGoalRecord}" rerender="table"/> &nbsp;&nbsp;-->
             <apex:commandButton value="Save and Add" action="{!saveAndAdd}" rerender="table"/> &nbsp;&nbsp;
              <!--apex:commandButton value="Reorder" action="{!Reorder}" rerender="table"/--> &nbsp;&nbsp;
           
            </div>
            <br/>
            <br/>
            <br/>
            <div align="center">
            <p style="font-weight:italic;font-size:16px;" >********* This information is for ‘CRM’ purposes only and is not intended as a replacement for the information maintained in other systems. *********</p>
            </div>
    </apex:form>
</apex:page>
 
I am having an odd query timeout error and I don't know why. I am really confused as to why it is timing out because it is only selecting one record. It typically happens on the weekends (I don't know if that would make any difference). Here is the error message as well as the query.

User [dataintegration@ampf.com.aacprod].  SOSQL [Select LastModifiedDate From Event Where Activity_Type__c!='Email' AND Activity_Type__c!='Internal Activity' AND Event_Status__c='Appointment Held' AND IsDeleted=False ORDER BY LastModifiedDate DESC NULLS LAST LIMIT 1].  Fault code [sf:QUERY_TIMEOUT].  Reason [QUERY_TIMEOUT: Your query request was running for too long.].

Does anyone have any clues as to why this is happening?

 
Hello,

I have a quick question about web services and SSL authentication.
I am trying to host a web service here is the class which I have designed.

global with sharing class CalendaringPlugin{ 

    webservice static List<Event> GetEvents(String ClientID, Date StartDT, Date EndDT){
        string resCode = 'false';
        String CLID = [SELECT ID from Account WHERE CL_ID__c =: ClientID].id;
        List<Event> EventList = [SELECT Owner.Name, Adv_ID__c, StartDateTime, Activity_Status__c, EndDateTime, Sub_Activity_Type__c, CreatedDate, ID, location from Event WHERE What.id =: CLID AND Share_Appointment_With_Client__c = true];
        List<Event> NewEventList = new List<Event>();
        for (Event e: EventList){
        if (StartDT <= e.StartDateTime && e.StartDateTime <= EndDT){
        NewEventList.add(e);
        }
        }
        Return NewEventList;
        }
}

I have developed the class, obtained and uploaded a CA signed certificate, shared the class WSDL, the partner WSDL, and the certificate keystore file with the designers of the web service. Note that I have not added their site to the list of remote sites.

But here is my problem, the designers are seeing a response from this web service wether or not they have signed the message.

So here is my question - how do I enforce the client to authenticate? I don't want to just send this response ( neweventlist ) for just anyone. Am I supposed to add more to this class?

Thanks for your help and time, I really appreciate it.
Hello all,

I have a quick question about web services and SSL authentication.
I am trying to host a web service here is the class which I have designed.

global with sharing class CalendaringPlugin{ 

    webservice static List<Event> GetEvents(String ClientID, Date StartDT, Date EndDT){
        string resCode = 'false';
        String CLID = [SELECT ID from Account WHERE CL_ID__c =: ClientID].id;
        List<Event> EventList = [SELECT Owner.Name, Adv_ID__c, StartDateTime, Activity_Status__c, EndDateTime, Sub_Activity_Type__c, CreatedDate, ID, location from Event WHERE What.id =: CLID AND Share_Appointment_With_Client__c = true];
        List<Event> NewEventList = new List<Event>();
        for (Event e: EventList){
        if (StartDT <= e.StartDateTime && e.StartDateTime <= EndDT){
        NewEventList.add(e);
        }
        }
        Return NewEventList;
        }
}

I have developed the class, obtained and uploaded a CA signed certificate, shared the class WSDL, the partner WSDL, and the certificate keystore file with the designers of the web service. Note that I have not added their site to the list of remote sites.

But here is my problem, the designers are seeing a response from this web service wether or not they have signed the message.

So here is my question - how do I enforce the client to authenticate? I don't want to just send this response ( neweventlist ) for just anyone. Am I supposed to add more to this class?

Thanks for your help and time, I really appreciate it.

 
Hello,

I need some help - we are using person acocunts and we have an embedded visualforce page on the account's page layout.
For some reason, when an account's record is open, the UI automatically scrolls to that visualforce page, and I don't know why.

Here is the VF page code - 

<apex:page standardController="Account" extensions="GoalOperations1" id="page">
 
  
 
   <script>
     function ChangeRow1(first , second){
        var size='{!sizeofGoal}';
               
         if(parseInt(size, 10) < parseInt(first, 10) || first==null || first ==0 || parseInt(first, 10)<0 ){
          alert('row number '+first+' does not Exist');
        document.getElementById('page:form:pageblock:table1:'+second+':number').value =parseInt(second, 10)+1;         
          
         }else{
          ChangeRow(first,second);
          }
     
     }
   </script>
 
      <apex:form id="form">
    <apex:variable var="rowNum1" value="{!0}"  />
     <apex:variable var="order" value="{!0}"  />
    <apex:pageMessages id="id1"></apex:pageMessages>
         <apex:outputPanel id="table" >
        <apex:pageBlock title="Financial Concerns" id="pageblock" >
           
          <apex:variable var="rowNum" value="{!0}"  />
            <apex:pageBlockTable value="{!Goals}" var="g" id="table1" width="10%"  >
                    <apex:column headerValue="Order" id="order" width="5%"><apex:inputField onchange="ChangeRow1(document.getElementById('{!$Component.number}').value,'{!rowNum}');"  id="number" style="width:30px;text-align:center;" value="{!g.Order__c}" /> </apex:column>
                  <apex:column headerValue="Tier 1" id="col1" width="10%"> <apex:inputField value="{!g.Level_1_Goals__c}" />  </apex:column>
                  <apex:column headerValue="Tier 2" id="col2" width="10%"><apex:inputField value="{!g.Level_2_Goals__c}"/>  </apex:column>
                  <apex:column headerValue="Description" width="10%" >
                
                    <apex:inputField value="{!g.Comments__c}"  />
                  
                    </apex:column>
                  <apex:column headerValue="Time Frame" id="col4" width="10%"><apex:inputField value="{!g.Time_Frame__c}" />  </apex:column>
                  <apex:column headerValue="Validated Date" id="col6" width="10%"><apex:inputField value="{!g.Validated_Date__c}"  />  </apex:column>
                  <apex:column headerValue="Status" id="col5" width="10%"><apex:inputField value="{!g.Status__c}" />  </apex:column>
                  <apex:column headerValue="Action" width="10%">
                    <apex:commandLink value="Delete" action="{!processDeleted}" reRender="table" >
                           <apex:param value="{!rowNum}" name="index" />
                        </apex:commandLink>
                     <apex:variable var="rowNum" id="rowNum" value="{!rowNum+1}"/>                
                  </apex:column>
                   
            </apex:pageBlockTable>       
            <apex:actionFunction name="ChangeRow" status="status"  action="{!UpdateRow}" rerender="table">
             <apex:param value="" name="first"  > </apex:param>
             <apex:param value=""  name="Second"/>        
            
             </apex:actionFunction>
            
              <apex:outputpanel >
                <apex:actionstatus id="status">
                <apex:facet name="start">
                <div id="el_loading" style="background-color: #fbfbfb;height: 100%;opacity:0.65;width:100%;">
                <div style="top: 74.2px; width: 91px;">
                <img src="/img/loading.gif" title="Please Wait…" />
                <span>Loading…</span>
                </div>
                </div>
                </apex:facet>
                </apex:actionstatus>
             </apex:outputpanel>
           
        </apex:pageBlock>
        </apex:outputPanel>
          <div align="center">
             
              <apex:commandLink value="Save" action="{!SaveAndClose}" target="_parent" styleClass="btn" style="text-decoration:none;padding:4px;"/>
              <!--<apex:commandButton value="Save" action="{!UpsertGoalRecord}" rerender="table"/> &nbsp;&nbsp;-->
             <apex:commandButton value="Save and Add" action="{!saveAndAdd}" rerender="table"/> &nbsp;&nbsp;
              <!--apex:commandButton value="Reorder" action="{!Reorder}" rerender="table"/--> &nbsp;&nbsp;
           
            </div>
            <br/>
            <br/>
            <br/>
            <div align="center">
            <p style="font-weight:italic;font-size:16px;" >********* This information is for ‘CRM’ purposes only and is not intended as a replacement for the information maintained in other systems. *********</p>
            </div>
    </apex:form>
</apex:page>
 
I am having an odd query timeout error and I don't know why. I am really confused as to why it is timing out because it is only selecting one record. It typically happens on the weekends (I don't know if that would make any difference). Here is the error message as well as the query.

User [dataintegration@ampf.com.aacprod].  SOSQL [Select LastModifiedDate From Event Where Activity_Type__c!='Email' AND Activity_Type__c!='Internal Activity' AND Event_Status__c='Appointment Held' AND IsDeleted=False ORDER BY LastModifiedDate DESC NULLS LAST LIMIT 1].  Fault code [sf:QUERY_TIMEOUT].  Reason [QUERY_TIMEOUT: Your query request was running for too long.].

Does anyone have any clues as to why this is happening?