• RICARDO PALMA
  • NEWBIE
  • 85 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 24
    Replies
Hi,
I'm getting this error: TASKRAY:Too many SOQL queries: 201 running the following batch process. 
I think I have to bulkify the batch process taking out of the for loop this line:
Map<String,Id> retInfo = TASKRAY.trTaskBoardController.cloneProjectsReturnIds(projectInfo, cloneOptions);   
My question is what is the best way to take the line out an pass the parameters and call the class.

global class TaskRayProjectCreated implements Database.Batchable<sObject>, Database.Stateful{
public String query;
Map<String,Map<String,Object>> projectInfo = new Map<String,Map<String,Object>>();
Map<String,Object> projectDetails = new Map<String,Object>();
Map<String,Object> cloneOptions = new Map<String,Object>();
List<FRC_Batch_Integration__c> recordsToUpdate = new List<FRC_Batch_Integration__c>();

global Database.QueryLocator start(Database.BatchableContext BC) {

/* QUERY ALL FRC BATCH INTEGRATION RECORDS WITH Taskray_Project_Created  = FALSE*/   
 query = 'Select Id, Type__c, TaskRay_Project_Template_ID__c , Advertiser_FRC_Site_ID__c, Advertiser_Account_Name__c , Product_Short_Name__c, Account_SF_ID__c From FRC_Batch_Integration__c Where TaskRay_Project_Created__c = false and Type__c = \'NEW\' and TaskRay_Project_Template_ID__c  != null Order by CreatedDate asc';
 return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, List<FRC_Batch_Integration__c> scope ) {
  for (FRC_Batch_Integration__c  frcRecord  :scope){
    projectDetails.put('templateProjectId', frcRecord.TaskRay_Project_Template_ID__c);
    projectDetails.put('newName', frcRecord.Advertiser_FRC_Site_ID__c + '-' + frcRecord.Advertiser_Account_Name__c + '-' + frcRecord.Product_Short_Name__c);
    projectDetails.put('depCloneBasedOnProjectStart', true);
    projectDetails.put('newStartDate', Date.today());
    projectDetails.put('newAccount', frcRecord.Account_SF_ID__c);
    projectInfo.put   ('specialid1',projectDetails);
    cloneOptions.put('assignInactiveToCurrent', true);
    
    frcRecord.TaskRay_Project_Created__c = true;
    recordsToUpdate.add(frcRecord);
    system.debug ('???????? ' +  frcRecord.Account_SF_ID__c); 
   Map<String,Id> retInfo = TASKRAY.trTaskBoardController.cloneProjectsReturnIds(projectInfo, cloneOptions);   
  }
}
global void finish(Database.BatchableContext BC) {
update recordsToUpdate;
}
}
 
Hi, 
I'm having a hard time covering this Controller Extension,  any example code?
Thanks!!!

public with sharing class currentbilling {
public final Account acc {get; set;}
public integer countActRec {get; set;}
public  Object sumAmount{set;get;}
Set<ID> countr = new Set<ID>();  
   public currentbilling(ApexPages.StandardController controller) {
       this.acc = (Account)controller.getRecord();
   }
   public List<OpportunityLineItem> oppoproRecords{get;set;} 
public void FetchData() {
  oppoproRecords = [SELECT Id, Opportunityid, Opportunity.Name ,  PricebookEntry.Product2.Name , Discounted_Rate__c, Advertiser_Account__c,  Opportunity.Contract_End_Date__c  FROM OpportunityLineItem Where Advertiser_Account__c = :acc.id and  Opportunity.StageName  = 'Contract Executed' and (Cancellation_Date__c = null or Cancellation_Date__c > Today) ];
if(oppoproRecords.isEmpty()){
  ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'There is no executed opportunities with actives products for this account.'));
}
  for (OpportunityLineItem rec : oppoproRecords) {
   countr.add(rec.Opportunityid);
   }
  countActRec =   [SELECT count() From Opportunity Where id in :countr];
  AggregateResult[] groupedResults   = [SELECT SUM(Discounted_Rate__c)aver FROM OpportunityLineItem Where Advertiser_Account__c = :acc.id and  Opportunity.StageName  = 'Contract Executed' and (Cancellation_Date__c = null or Cancellation_Date__c > Today)];
  sumAmount = groupedResults[0].get('aver');
}
}
------------
Hi,
I have a custom visualforce page with a lookup field that I want to save.

For some reason it looks like I'm not able to pass the lookup value from the visualforce page to the controller 

VisualForce Page:
<apex:inputField value="{!OpportunityLineItem.FRMS_Customer_Social_Media_Contact_Alt1__c}" >
<apex:param name="alt1" value="{!OpportunityLineItem.FRMS_Customer_Social_Media_Contact_Alt1__c}" assignTo="{!ContactAlt1}"/>
</apex:inputField>

Controller:
public class DisplayingActivationFields {
public id   ContactAlt1{get;set;}
list <OpportunityLineItem> proList = [SELECT Id, Product2id, OpportunityId, Advertiser_Account__c, Fullfillment_Rep__c, Approved_by_FRSocial__c, Rejected_by_FRSocial__c, Rejection_Comment__c, FRMS_Customer_Social_Media_Contact_Alt1__c, FRMS_Customer_Social_Media_Contact_Alt2__c, FRMS_Customer_Social_Media_Contact_Alt3__c FROM OpportunityLineItem  Where id=:ApexPages.currentPage().getParameters().get('id')];

 public displayingactivationfields(ApexPages.StandardController controller) {
    this.oppprorec = (OpportunityLineItem)controller.getRecord();
  }

public void  FetchData() {
some code...
}
public PageReference save(){ 
for (OpportunityLineItem rid :proList){
rid.FRMS_Customer_Social_Media_Contact_Alt1__c = ContactAlt1;
system.debug('&&&&&&&&& '+ ContactAlt1); ContactAlt1 returns NULL all the time after clicking the save buttton.

}
}

update proList;

}

}


 
Hi,
I have a custom visualforce page and I want a to enable a button only after all the required fields have been entered.
Any example code?
Thanks. 
Hi,
I have a visualforce page that is going to call another visual force page after clicking a button in a <apex:pageBlockButtons >.
Where I click the button Enter Data the doUnlink function is executed and call a method in a another class. On that class I have a call to another visualforce page. The issue is that I'm tying to pass Prod.Id to used when calling the new visualforce page but for some reason the id is  not passing to the class.

Here is the part of the code 
<apex:actionFunction name="doUnlink" action="{!openPage}" rerender="refresh" />
<apex:pageBlockTable value="{!listProducts}" var="Prod">
         <apex:column headerValue="Click to add info">
        <apex:commandButton value="Enter Data" onclick="doUnlink();" >
        <apex:param id="oppProdId" value="{!Prod.Id}" assignTo="{!oppprorec}"/>
        </apex:commandButton>
    </apex:column>
    
</apex:pageBlockTable>
Thanks
 
Hi,
I want to know what is the best way to compare two set <id>
 Set <id> a = new Set<id>();   
 Set <id> b = new Set<id>();  
Set <id> accToDeactivate = new Set<id>();    

I want to know if the any of the Ids on  are on b, if the are not I want add those ids to another set
I tried this code but is not working, it is getting me all the id on b.
 If
for(Id objId: b){
            if(a.contains(objId)) {
//do nothing 
           }else{
 accToDeactivate.add(objId);
            }
      }
Hi,
I have the following dynamic query in a batch process:
I have a lookup relation between Tracking_Number__c  and Account but I'm getting this error:

Didn't understand relationship 'Account_Id__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropri

String query;
global Database.QueryLocator start(Database.BatchableContext BC) {
query = 'SELECT Id, Marchex_Campaign_Id__c, Tracking_Phone_Number__c, Opportunity_Product_Id__c (Select Marchex_Account_Id__c From Account_Id__r) FROM Tracking_Number__c Where  Deactivated_Date__c <= Today and Deactivation_Processed__c = true';
return Database.getQueryLocator(query);
}
Thanks
Hi,
I'm getting Too many SOQL queries: 101 but my select is not inside of a loop.
trigger MyAccountTrigger on Account (before update) {
any ideas?
Thanks.

if (Trigger.isBefore) { 
        if (Trigger.isUpdate) {
           for (Account aRecord  : trigger.new){
                    if (aRecord.OwnerId != trigger.oldMap.get(aRecord.id).OwnerId){
                    MyAccountClassOwnerChange.Accountownerchanged();
                }
            }
 
        }
}
}

public class MyAccountClassOwnerChange {

    public static void Accountownerchanged(){
        Set<Id> newAccountId = new Set <Id>();
        Set<Id> newAccountOwner = new Set <Id>();
        Date newLastAcctivityDate;
        
        /* Changing the Account Owner this For Loop set the IDs for the new account and new owner id*/  
        for (Account aRecord  : (List<Account>)Trigger.new) {
               newAccountId.add(aRecord.Id);
               newAccountOwner.add(aRecord.OwnerId);
        }
        
        /* Here I'm getting the Max (StartDatetime) which is equal to ActivityDate. I'm not using the ActicityDate because
         * field ActivityDate does not support aggregate operator MAX.
        */
        AggregateResult[] groupedResults = [SELECT max(StartDateTime) maxDate From Event Where Whatid in :newAccountId and Ownerid in :newAccountOwner and Completed_Date__c != null];
        For (AggregateResult ar :groupedResults) {
            newLastAcctivityDate =  Date.valueOf(ar.get('MaxDate'));
        }
        
       /*Here I'm updating the Last Contacted Day with the newLastAcctivityDate
        * Note: an update is not necesary because I'm setting Last Contacted Day value as part of trigger.new and 
        * because the Trigger is a before update, I can set data defore the update is executed.
        */ 
       for (Account aRecord  : (List<Account>)Trigger.new) {
           aRecord.Last_Contacted_Day__c = newLastAcctivityDate;
       }
}
}
global class EvergreenOppoRevenueScheduleBatch implements Database.Batchable<sObject> {
String query;
id firstId = null;    
global Database.QueryLocator start(Database.BatchableContext BC) {
    /*This SOQL gets all the records (Evergreen Opportunities) on the sObject (OpportunityLineItemSchedule)
    WHERE OpportunityLineItem.Opportunity.StageName = 'Contract Executed' 
    and OpportunityLineItem.Opportunity.TFBA__c =  True 
    and OpportunityLineItem.Opportunity.Contract_Status__c <> 'Cancelled' 
    and OpportunityLineItem.Opportunity.Contract_Status__c <> 'Renewed'  
    and OpportunityLineItem.Cancellation_Date__c = null  
    and  OpportunityLineItem.HasRevenueSchedule = True 
    and  OpportunityLineItem.PricebookEntry.Product2.Media__r.Automatic_Revenue_Schedule__c  = True 
    This query can get up to 50,000,000 records 
     */
     
return Database.getQueryLocator([SELECT OpportunityLineItemId, ScheduleDate, OpportunityLineItem.Number_of_Billings__c, OpportunityLineItem.Discounted_Rate__c  From OpportunityLineItemSchedule Where OpportunityLineItem.Opportunity.StageName = 'Contract Executed' and OpportunityLineItem.Opportunity.TFBA__c =  True and OpportunityLineItem.Opportunity.Contract_Status__c <> 'Cancelled' and OpportunityLineItem.Opportunity.Contract_Status__c <> 'Renewed'  and OpportunityLineItem.Cancellation_Date__c = null  and  OpportunityLineItem.HasRevenueSchedule = True and  OpportunityLineItem.PricebookEntry.Product2.Media__r.Automatic_Revenue_Schedule__c  = True Order By OpportunityLineItemId DESC]);
}
 
List<OpportunityLineItemSchedule> addrecs = new List<OpportunityLineItemSchedule>();   
    
/*This is the Loop for the Query scope*/    
global void execute(Database.BatchableContext BC, List<OpportunityLineItemSchedule> scope) {

/*Creating a unique ID Set of the all Opportunities*/
Set<ID> oppProductId = new Set<ID>();
  For (OpportunityLineItemSchedule recuni : scope)  {
     oppProductId.add(recuni.OpportunityLineItemId );   
 }

/*Creating a list of all Max Date for each opportunity line item Ids product from the OpportunityLineItemSchedule sObject using the unique list */    
AggregateResult[] groupedResults = [SELECT Max(ScheduleDate) MaxDate, OpportunityLineItemId oppid FROM OpportunityLineItemSchedule Where OpportunityLineItemId in :oppProductId Group By OpportunityLineItemId Order By OpportunityLineItemId];

   
/*Looping through all the unique Ids to get the Discounted Rate and Number of  Billings */
For (OpportunityLineItem opprec : [Select id , Discounted_Rate__c, Number_of_Billings__c From OpportunityLineItem where id in :oppProductId Order By Id]) {   
       Date maxDatevar;
       String stridLineItem;
       Id idLineItem;
   
 /*For each record now go throught the following loop find the Max Date. When the Max Date is found get out to the loop */
       For (AggregateResult ar :groupedResults) {
           
            stridLineItem = String.ValueOf(ar.get('oppid'));
            idLineItem = Id.ValueOf(stridLineItem);
            If (opprec.Id ==  idLineItem) {
            maxDatevar = Date.valueOf(ar.get('MaxDate'));
                      
            if (date.today() >=  MaxDatevar){
                Integer Days = 0;
                Date oldServiDate = MaxDatevar;
                Days =  Date.daysInMonth(oldServiDate.year(), oldServiDate.month());
                oldServiDate = oldServiDate + Days;

                for (Integer countBillings = 1 ; countBillings <= opprec.Number_of_Billings__c; countBillings++  ){
                OpportunityLineItemSchedule oppS = new OpportunityLineItemSchedule();
                oppS.OpportunityLineItemId = idLineItem;
                oppS.Type = 'Revenue';
                oppS.ScheduleDate = oldServiDate;
                oppS.Revenue = opprec.Discounted_Rate__c;
                Days =  Date.daysInMonth(oldServiDate.year(), oldServiDate.month());
                oldServiDate = oldServiDate + Days;
                addrecs.add(oppS);
                }  
            }
          break; /*Exit the loop after the record is found.*/
              
          }
           
        }
}
 

  Insert addrecs; /*Insert all the records on the OpportunityLineItemSchedule*/

}
    

global void finish(Database.BatchableContext BC) {
}
}
I think problem is my nested loop, base on the info that I found online. Any ideas how to fix this issue?
Thanks.
Hi,
I have a checkbox and a button (hide button) and I would like to select the checkbox an automatically click the button.
Thaks.
Hi,
I have an situation with the setredirect(true) calling a second visual force Page.
I want to pass a list of ids from Page1 to Page2 to be able use those Ids to filter the information on Page2, but when I open Page2 the list of :Ids disappear and I got all the records witch filtering any. If setup setredirect(false) using the system.debug I can see the list of ids that I want to see in Page2 but the page doesn't open.

Thanks. 
Hi,
I'm having some problems with the callout Governor Limits doing callouts in a Apex Class (Error: Too many call outs) . Doing some research I found that is posible to avoid this issue with Batch Apex, but I can't find a clear example and also I found some Batch Apex Governor Limits (Call out 10) I'm not sure if I'm reading this right but 10 call out in a Batch Apex is not going to help me. 
Can someone please help me with an example.
Thanks.

 
Hi, 
I have a Visualforce page, displaying multiples records on a pageBlockTable. I would like to add a line or a break when the account changes.
Example:
Account:                Price:
Abc                        3.00
Abc                        4.00
Abc                        2.00


Dallas Acc              2.00
Dallas Acc              5.00

Thanks.
Hi,
I'm trying to setup a date format on a date field in a costume visual force page.
Whenever I click save I upsert a list of records saving the date on a date field.
But the field is saving the date on this format : Mon Jun 01 00:00:00 GMT 2015
What I want is save the date on this format: MM'/'dd'/'yyyy.
Here is my code:
<apex:pageBlockTable value="{!ListAllTrackingRec}" var="Prod">
<apex:column >
 <apex:facet name="header">Provisioned <br/>Date </apex:facet>
{!Prod.Provisioned_Date__c }
</apex:column>
</apex:pageBlockTable>

I found a solution on the community but is not working for me. When I use it my date column disappear.
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!Prod.Provisioned_Date__c }" />
</apex:outputText>

Thanks.
 
Hi,
Clicking custom button in a visual force page, I would like to call a confirmation pop-up box message with three buttons(Ye, No, Cancel). Is there any way to do it.
Clicking Yes call controller test1
Clicking No call controlles test2
Clicking Cancel stay on the same page.

Thanks 
Hi,
I'm doing an integration with a third party and I have to send the accid to the third party to get some information back. I got the result when I type the accid, but I what I really need to do is set up a params as variable not a literal.

Here is what I want to do:
This doesn't work.
Just for testing I'm setting up manually the accid but this value is going to be the accid on the opportunity. The values is going to different base on the opportunity.

string accid = "CtjSFlLYIls4-gAe";
string s = '{"jsonrpc": "2.0","id": 1,"method": "acct.phone.get","params": [accid]}';

I got an error: {"jsonrpc":"2.0","error":{"message":"invalid JSON in request body","code":-32700}}

It looks like I'm not using the right JSON format to set a parameter. 

But when I type the id on the params I got the information back.
string s = '{"jsonrpc": "2.0","id": 1,"method": "acct.phone.get","params": ["CtjSFlLYIls4-gAe"]}'; 

I hope someone can help me.
Thanks.
 
Hi,
I would like to be able to integrated SalesForce with Marchex (Tracking Calls). Basically I need to click a button in SalesForce got to Marchex get a phone number for the Account for example and update the phone number  back in Salesforce.

Any body with an example how to do it?
Thanks.
Hi I'm having some issue trying to generate a class from WSDL document.
I'm getting Error: Failed to parse wsdl: Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}schema

Here is part of my WSDL document. 

<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/StandardCallAPI/SCAPI" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/StandardCallAPI/SCAPI">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/StandardCallAPI/SCAPI">
<s:import namespace="http://www.w3.org/2001/XMLSchema"/>
<s:element name="CreateUser">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="LoginUsername" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="LoginPassword" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="UserExternalID" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="AdvertiserExternalID" type="tns:ArrayOfString"/>
<s:element minOccurs="0" maxOccurs="1" name="NewUsername" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="NewPassword" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="NewName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="NewEmail" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="phone" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="fax" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ExpirationDate" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfString">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="CreateUserResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="CreateUserResult" type="s:boolean"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="UpdateUser">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="LoginUsername" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="LoginPassword" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="UserExternalID" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="AdvertiserExternalID" type="tns:ArrayOfString"/>
<s:element minOccurs="0" maxOccurs="1" name="NewUsername" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="NewPassword" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="NewName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="NewEmail" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="phone" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="fax" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ExpirationDate" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="UpdateUserResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="UpdateUserResult" type="s:boolean"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DeleteUser">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="LoginUsername" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="LoginPassword" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="UserExternalID" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DeleteUserResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="DeleteUserResult" type="s:boolean"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="RetrievePermissionByUser">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="LoginUsername" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="LoginPassword" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="UserExternalID" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="AdvertiserExternalIDs" type="tns:ArrayOfString"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="RetrievePermissionByUserResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="RetrievePermissionByUserResult" type="s:boolean"/>
<s:element minOccurs="0" maxOccurs="1" name="AdvertiserExternalIDs" type="tns:ArrayOfString"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="RetrieveUserByPermission">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="LoginUsername" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="LoginPassword" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="AdvertiserExternalID" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="UserExternalIDs" type="tns:ArrayOfString"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="RetrieveUserByPermissionResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="RetrieveUserByPermissionResult" type="s:boolean"/>
<s:element minOccurs="0" maxOccurs="1" name="UserExternalIDs" type="tns:ArrayOfString"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<wsdl:service name="APIWebService">
<wsdl:port name="APIWebServiceSoap" binding="tns:APIWebServiceSoap">
<soap:address location="http://api.standardcall.com/scportal.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Thanks.
Hi all,

I have a VF page that creates a json file after a button have been clicked. The problem is that the file is always downloaded on  C:\User\Download 
I can change the location on the browser, but I don't want to do that because I will have all kind of files downloaded by the users.
This action will be executed by multiple users.

I'm open to any suggestions, but here is what I need to do.
1. I want to be able to save the on a ftp server. This is my first option. I did some research and it looks like is not way to connect to FTP server using Apex.
or 
2. I want to able to save the file on a different map network drive.

I tried creating a  .bat file to move all the .json files from C:\User\Download  to my ftp server setting a task. The problem is that if the user turn off the pc before the task is executed the file never going to be moved to the FTP server or the map drive. I need something more REAL TIME.
1. Click the button
2. Save the file on the ftp or the map drive. 

Here is my VF page
 
<apex:page Controller="IDR" sidebar="false" action="{!fetch}" contentType="text/plain/#{!media.City_Code__c}_{!IssueDate}.json" cache="false">
{"mediaCode":"{!media.City_Code__c}","mediaName":"{!media.Name}","issueDate":"
<apex:outputText value="{!IssueDate}"/>
","secondWrap":false,"ads":[
<apex:repeat value="{!LstQuotes}" var="Listrec">
{"adId":"<apex:outputText value="{!Listrec.QuoteNumber}" />
","billingNumber":"<apex:outputText value="{!Listrec.AX_Arrangement_ID__c}" />
","filename":"<apex:outputText value="{!Listrec.Ad_Name__c}" />
","type":"<apex:outputText value="{!Listrec.Type__c}" />
","size":"<apex:outputText value="{!Listrec.Size__c}" />
","version":"<apex:outputText value="{!Listrec.Version__c}" />
","section":"<apex:outputText value="{!Listrec.Ad_Name__c}" />
","bleedCode":"<apex:outputText value="{!Listrec.Bleed_Code__c}" />
","properties":[
<apex:variable value="{!0}" var="rowNum"/>
<apex:repeat value="{!Listrec.QuoteLineItems}" var="Listrec2" rendered="{!Listrec.QuoteLineItems.size > 0}" >
<apex:variable var="rowNum" value="{!rowNum + 1}"/>
<apex:variable var="totRec" value="{!Listrec.Count_QuoteLineItemRec__c}"/>

{"propertyid":"<apex:outputText value="{!Listrec2.Account_SF_ID__c}"/>
","name":"<apex:outputText value="{!IF(rowNum == totRec, Listrec2.Advertiser_Account__r.Name + '}',  Listrec2.Advertiser_Account__r.Name + '},')}"/>
</apex:repeat>
]},
</apex:repeat>
</apex:page>

Thanks.
Hi, 
I'm tring to write a text file with this information:
Quote1
QuoteLineItem1
QuoteLineItem2
QuoteLineItem3 ....

Quote2
QuoteLineItem1
QuoteLineItem2
QuoteLineItem3 .... etc

I'm able to write all the info for Quote1 and Quote2 etc, but I'm not able to write the details info for each Quote after each Quote record.

I have a button calling a VF page calling a controller 
Here is my Class 
public class IDR
{

    public Media__c media {get;set;}
    public List <Quote> LstQuotes { get; set; }
    public List <QuoteLineItem> LstQuotelineitem { get; set; }
  
    public void fetch()
    {
     String theId =  Apexpages.currentpage().getparameters().get('City');
     String strMediaID =  Apexpages.currentpage().getparameters().get('MediaId');       
               
     media = [SELECT m.City_Code__c, m.Name, m.Current_Issue_Date__c FROM Media__c m WHERE City_Code__c =
     :theId];
 
   LstQuotes = [SELECT q.id,q.QuoteNumber, q.Ad_Name__c,q.Type__c, q.Size__c,  q.Version__c, q.Bleed_Code__c,
   (Select QuoteLineItem.Id, QuoteLineItem.QuoteId From QuoteLineItems)
   From Quote q
   where City_Code__c = :theId and q.Media_Name__c =: strMediaID];


       
  for(Quote q:LstQuotes )
   {
       for (QuoteLineItem qli : q.QuoteLineItems)
       {
           // I can see my subquery info here. Now how can I send it back to my VF page?
            system.debug('Quote Line Items Records ' + qli.id );
         
       }
   }
     
  }   

}
/*********/
Here is my VF page

<apex:page Controller="IDR" sidebar="false" action="{!fetch}" contentType="text/plain/#emp.txt" cache="false">

{"mediaCode":"{!media.City_Code__c}","mediaName":"{!media.Name}","issueDate":"
<apex:outputText value="{0,date,yyyyMMdd}">
<apex:param value="{!media.Current_Issue_Date__c}" />
</apex:outputText>","secondWrap":false,"ads":[

<apex:repeat value="{!LstQuotes}" var="Listrec">
{"adId":"<apex:outputText value="{!Listrec.QuoteNumber}" />
","filename"<apex:outputText value="{!Listrec.Ad_Name__c}" />
,"type"<apex:outputText value="{!Listrec.Type__c}" />
,"size"<apex:outputText value="{!Listrec.Size__c}" />
,"version"<apex:outputText value="{!Listrec.Version__c}" />
,"section"<apex:outputText value="{!Listrec.Ad_Name__c}" />
,"bleedCode"<apex:outputText value="{!Listrec.Bleed_Code__c}" />
,"properties":["propertyid":

<apex:repeat value="{!LstQuotelineitem}" var="Listrec2">
// I think my details records have to be here.
</apex:repeat>

</apex:repeat>


</apex:page>

Thanks...

Hi, 
I'm having a hard time covering this Controller Extension,  any example code?
Thanks!!!

public with sharing class currentbilling {
public final Account acc {get; set;}
public integer countActRec {get; set;}
public  Object sumAmount{set;get;}
Set<ID> countr = new Set<ID>();  
   public currentbilling(ApexPages.StandardController controller) {
       this.acc = (Account)controller.getRecord();
   }
   public List<OpportunityLineItem> oppoproRecords{get;set;} 
public void FetchData() {
  oppoproRecords = [SELECT Id, Opportunityid, Opportunity.Name ,  PricebookEntry.Product2.Name , Discounted_Rate__c, Advertiser_Account__c,  Opportunity.Contract_End_Date__c  FROM OpportunityLineItem Where Advertiser_Account__c = :acc.id and  Opportunity.StageName  = 'Contract Executed' and (Cancellation_Date__c = null or Cancellation_Date__c > Today) ];
if(oppoproRecords.isEmpty()){
  ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'There is no executed opportunities with actives products for this account.'));
}
  for (OpportunityLineItem rec : oppoproRecords) {
   countr.add(rec.Opportunityid);
   }
  countActRec =   [SELECT count() From Opportunity Where id in :countr];
  AggregateResult[] groupedResults   = [SELECT SUM(Discounted_Rate__c)aver FROM OpportunityLineItem Where Advertiser_Account__c = :acc.id and  Opportunity.StageName  = 'Contract Executed' and (Cancellation_Date__c = null or Cancellation_Date__c > Today)];
  sumAmount = groupedResults[0].get('aver');
}
}
------------
Hi,
I have a custom visualforce page with a lookup field that I want to save.

For some reason it looks like I'm not able to pass the lookup value from the visualforce page to the controller 

VisualForce Page:
<apex:inputField value="{!OpportunityLineItem.FRMS_Customer_Social_Media_Contact_Alt1__c}" >
<apex:param name="alt1" value="{!OpportunityLineItem.FRMS_Customer_Social_Media_Contact_Alt1__c}" assignTo="{!ContactAlt1}"/>
</apex:inputField>

Controller:
public class DisplayingActivationFields {
public id   ContactAlt1{get;set;}
list <OpportunityLineItem> proList = [SELECT Id, Product2id, OpportunityId, Advertiser_Account__c, Fullfillment_Rep__c, Approved_by_FRSocial__c, Rejected_by_FRSocial__c, Rejection_Comment__c, FRMS_Customer_Social_Media_Contact_Alt1__c, FRMS_Customer_Social_Media_Contact_Alt2__c, FRMS_Customer_Social_Media_Contact_Alt3__c FROM OpportunityLineItem  Where id=:ApexPages.currentPage().getParameters().get('id')];

 public displayingactivationfields(ApexPages.StandardController controller) {
    this.oppprorec = (OpportunityLineItem)controller.getRecord();
  }

public void  FetchData() {
some code...
}
public PageReference save(){ 
for (OpportunityLineItem rid :proList){
rid.FRMS_Customer_Social_Media_Contact_Alt1__c = ContactAlt1;
system.debug('&&&&&&&&& '+ ContactAlt1); ContactAlt1 returns NULL all the time after clicking the save buttton.

}
}

update proList;

}

}


 
Hi,
I have a visualforce page that is going to call another visual force page after clicking a button in a <apex:pageBlockButtons >.
Where I click the button Enter Data the doUnlink function is executed and call a method in a another class. On that class I have a call to another visualforce page. The issue is that I'm tying to pass Prod.Id to used when calling the new visualforce page but for some reason the id is  not passing to the class.

Here is the part of the code 
<apex:actionFunction name="doUnlink" action="{!openPage}" rerender="refresh" />
<apex:pageBlockTable value="{!listProducts}" var="Prod">
         <apex:column headerValue="Click to add info">
        <apex:commandButton value="Enter Data" onclick="doUnlink();" >
        <apex:param id="oppProdId" value="{!Prod.Id}" assignTo="{!oppprorec}"/>
        </apex:commandButton>
    </apex:column>
    
</apex:pageBlockTable>
Thanks
 
Hi,
I have the following dynamic query in a batch process:
I have a lookup relation between Tracking_Number__c  and Account but I'm getting this error:

Didn't understand relationship 'Account_Id__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropri

String query;
global Database.QueryLocator start(Database.BatchableContext BC) {
query = 'SELECT Id, Marchex_Campaign_Id__c, Tracking_Phone_Number__c, Opportunity_Product_Id__c (Select Marchex_Account_Id__c From Account_Id__r) FROM Tracking_Number__c Where  Deactivated_Date__c <= Today and Deactivation_Processed__c = true';
return Database.getQueryLocator(query);
}
Thanks
Hi,
I'm getting Too many SOQL queries: 101 but my select is not inside of a loop.
trigger MyAccountTrigger on Account (before update) {
any ideas?
Thanks.

if (Trigger.isBefore) { 
        if (Trigger.isUpdate) {
           for (Account aRecord  : trigger.new){
                    if (aRecord.OwnerId != trigger.oldMap.get(aRecord.id).OwnerId){
                    MyAccountClassOwnerChange.Accountownerchanged();
                }
            }
 
        }
}
}

public class MyAccountClassOwnerChange {

    public static void Accountownerchanged(){
        Set<Id> newAccountId = new Set <Id>();
        Set<Id> newAccountOwner = new Set <Id>();
        Date newLastAcctivityDate;
        
        /* Changing the Account Owner this For Loop set the IDs for the new account and new owner id*/  
        for (Account aRecord  : (List<Account>)Trigger.new) {
               newAccountId.add(aRecord.Id);
               newAccountOwner.add(aRecord.OwnerId);
        }
        
        /* Here I'm getting the Max (StartDatetime) which is equal to ActivityDate. I'm not using the ActicityDate because
         * field ActivityDate does not support aggregate operator MAX.
        */
        AggregateResult[] groupedResults = [SELECT max(StartDateTime) maxDate From Event Where Whatid in :newAccountId and Ownerid in :newAccountOwner and Completed_Date__c != null];
        For (AggregateResult ar :groupedResults) {
            newLastAcctivityDate =  Date.valueOf(ar.get('MaxDate'));
        }
        
       /*Here I'm updating the Last Contacted Day with the newLastAcctivityDate
        * Note: an update is not necesary because I'm setting Last Contacted Day value as part of trigger.new and 
        * because the Trigger is a before update, I can set data defore the update is executed.
        */ 
       for (Account aRecord  : (List<Account>)Trigger.new) {
           aRecord.Last_Contacted_Day__c = newLastAcctivityDate;
       }
}
}
global class EvergreenOppoRevenueScheduleBatch implements Database.Batchable<sObject> {
String query;
id firstId = null;    
global Database.QueryLocator start(Database.BatchableContext BC) {
    /*This SOQL gets all the records (Evergreen Opportunities) on the sObject (OpportunityLineItemSchedule)
    WHERE OpportunityLineItem.Opportunity.StageName = 'Contract Executed' 
    and OpportunityLineItem.Opportunity.TFBA__c =  True 
    and OpportunityLineItem.Opportunity.Contract_Status__c <> 'Cancelled' 
    and OpportunityLineItem.Opportunity.Contract_Status__c <> 'Renewed'  
    and OpportunityLineItem.Cancellation_Date__c = null  
    and  OpportunityLineItem.HasRevenueSchedule = True 
    and  OpportunityLineItem.PricebookEntry.Product2.Media__r.Automatic_Revenue_Schedule__c  = True 
    This query can get up to 50,000,000 records 
     */
     
return Database.getQueryLocator([SELECT OpportunityLineItemId, ScheduleDate, OpportunityLineItem.Number_of_Billings__c, OpportunityLineItem.Discounted_Rate__c  From OpportunityLineItemSchedule Where OpportunityLineItem.Opportunity.StageName = 'Contract Executed' and OpportunityLineItem.Opportunity.TFBA__c =  True and OpportunityLineItem.Opportunity.Contract_Status__c <> 'Cancelled' and OpportunityLineItem.Opportunity.Contract_Status__c <> 'Renewed'  and OpportunityLineItem.Cancellation_Date__c = null  and  OpportunityLineItem.HasRevenueSchedule = True and  OpportunityLineItem.PricebookEntry.Product2.Media__r.Automatic_Revenue_Schedule__c  = True Order By OpportunityLineItemId DESC]);
}
 
List<OpportunityLineItemSchedule> addrecs = new List<OpportunityLineItemSchedule>();   
    
/*This is the Loop for the Query scope*/    
global void execute(Database.BatchableContext BC, List<OpportunityLineItemSchedule> scope) {

/*Creating a unique ID Set of the all Opportunities*/
Set<ID> oppProductId = new Set<ID>();
  For (OpportunityLineItemSchedule recuni : scope)  {
     oppProductId.add(recuni.OpportunityLineItemId );   
 }

/*Creating a list of all Max Date for each opportunity line item Ids product from the OpportunityLineItemSchedule sObject using the unique list */    
AggregateResult[] groupedResults = [SELECT Max(ScheduleDate) MaxDate, OpportunityLineItemId oppid FROM OpportunityLineItemSchedule Where OpportunityLineItemId in :oppProductId Group By OpportunityLineItemId Order By OpportunityLineItemId];

   
/*Looping through all the unique Ids to get the Discounted Rate and Number of  Billings */
For (OpportunityLineItem opprec : [Select id , Discounted_Rate__c, Number_of_Billings__c From OpportunityLineItem where id in :oppProductId Order By Id]) {   
       Date maxDatevar;
       String stridLineItem;
       Id idLineItem;
   
 /*For each record now go throught the following loop find the Max Date. When the Max Date is found get out to the loop */
       For (AggregateResult ar :groupedResults) {
           
            stridLineItem = String.ValueOf(ar.get('oppid'));
            idLineItem = Id.ValueOf(stridLineItem);
            If (opprec.Id ==  idLineItem) {
            maxDatevar = Date.valueOf(ar.get('MaxDate'));
                      
            if (date.today() >=  MaxDatevar){
                Integer Days = 0;
                Date oldServiDate = MaxDatevar;
                Days =  Date.daysInMonth(oldServiDate.year(), oldServiDate.month());
                oldServiDate = oldServiDate + Days;

                for (Integer countBillings = 1 ; countBillings <= opprec.Number_of_Billings__c; countBillings++  ){
                OpportunityLineItemSchedule oppS = new OpportunityLineItemSchedule();
                oppS.OpportunityLineItemId = idLineItem;
                oppS.Type = 'Revenue';
                oppS.ScheduleDate = oldServiDate;
                oppS.Revenue = opprec.Discounted_Rate__c;
                Days =  Date.daysInMonth(oldServiDate.year(), oldServiDate.month());
                oldServiDate = oldServiDate + Days;
                addrecs.add(oppS);
                }  
            }
          break; /*Exit the loop after the record is found.*/
              
          }
           
        }
}
 

  Insert addrecs; /*Insert all the records on the OpportunityLineItemSchedule*/

}
    

global void finish(Database.BatchableContext BC) {
}
}
I think problem is my nested loop, base on the info that I found online. Any ideas how to fix this issue?
Thanks.
Hi,
I'm having some problems with the callout Governor Limits doing callouts in a Apex Class (Error: Too many call outs) . Doing some research I found that is posible to avoid this issue with Batch Apex, but I can't find a clear example and also I found some Batch Apex Governor Limits (Call out 10) I'm not sure if I'm reading this right but 10 call out in a Batch Apex is not going to help me. 
Can someone please help me with an example.
Thanks.

 
Hi, 
I have a Visualforce page, displaying multiples records on a pageBlockTable. I would like to add a line or a break when the account changes.
Example:
Account:                Price:
Abc                        3.00
Abc                        4.00
Abc                        2.00


Dallas Acc              2.00
Dallas Acc              5.00

Thanks.
Hi,
I'm trying to setup a date format on a date field in a costume visual force page.
Whenever I click save I upsert a list of records saving the date on a date field.
But the field is saving the date on this format : Mon Jun 01 00:00:00 GMT 2015
What I want is save the date on this format: MM'/'dd'/'yyyy.
Here is my code:
<apex:pageBlockTable value="{!ListAllTrackingRec}" var="Prod">
<apex:column >
 <apex:facet name="header">Provisioned <br/>Date </apex:facet>
{!Prod.Provisioned_Date__c }
</apex:column>
</apex:pageBlockTable>

I found a solution on the community but is not working for me. When I use it my date column disappear.
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!Prod.Provisioned_Date__c }" />
</apex:outputText>

Thanks.
 
Hi,
Clicking custom button in a visual force page, I would like to call a confirmation pop-up box message with three buttons(Ye, No, Cancel). Is there any way to do it.
Clicking Yes call controller test1
Clicking No call controlles test2
Clicking Cancel stay on the same page.

Thanks 
Hi,
I'm doing an integration with a third party and I have to send the accid to the third party to get some information back. I got the result when I type the accid, but I what I really need to do is set up a params as variable not a literal.

Here is what I want to do:
This doesn't work.
Just for testing I'm setting up manually the accid but this value is going to be the accid on the opportunity. The values is going to different base on the opportunity.

string accid = "CtjSFlLYIls4-gAe";
string s = '{"jsonrpc": "2.0","id": 1,"method": "acct.phone.get","params": [accid]}';

I got an error: {"jsonrpc":"2.0","error":{"message":"invalid JSON in request body","code":-32700}}

It looks like I'm not using the right JSON format to set a parameter. 

But when I type the id on the params I got the information back.
string s = '{"jsonrpc": "2.0","id": 1,"method": "acct.phone.get","params": ["CtjSFlLYIls4-gAe"]}'; 

I hope someone can help me.
Thanks.