• TechBlossom
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 0
    Replies

I am getting Invalid type error when I am running the class:

 

public with sharing class UpdateAccountCurrentBalance {

public UpdateAccountCurrentBalance(){

}

public void CurrentBalanceUpdate(){

aablCredentials__c cred = [Select username__c,password__c from aablCredentials__c];
OSI2MRMcurrBalanceWebservices.CFTFCUMemWsSoap ws = new OSI2MRMcurrBalanceWebservices.CFTFCUMemWsSoap();
//a.CServReturn response = osi.IsAlive(cur.username__c, cur.password__c);
//system.debug('Connect to OSI #################### '+response);
AccountBalances ab = ws.GetAccountBalances(cur.username__c, cur.password__c,'PERSNBR',1234);
//system.debug('The Account Balances for the current member is #################### '+response);
}

}

 

The WSDL for the above class is:

//Generated by wsdl2apex

public class OSI2MRMcurrBalanceWebservices {
public class IsAliveResponse_element {
public OSI2MRMcurrBalanceWebservices.CServReturn IsAliveResult;
private String[] IsAliveResult_type_info = new String[]{'IsAliveResult','http://#######.com/FTFCUMemWs','CServReturn','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://#######.com/FTFCUMemWs','true','false'};
private String[] field_order_type_info = new String[]{'IsAliveResult'};
}
public class GetAccountBalancesResponse_element {
public OSI2MRMcurrBalanceWebservices.AccountBalances AccountBalances;
private String[] AccountBalances_type_info = new String[]{'AccountBalances','http://#######.com/FTFCUMemWs','AccountBalances','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://#######.com/FTFCUMemWs','true','false'};
private String[] field_order_type_info = new String[]{'AccountBalances'};
}
public class CFTFCUMemWsSoap {
public String endpoint_x = 'http://#######/FTFCUMemWs/FTFCUMemWs.asmx';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
private String[] ns_map_type_info = new String[]{'http://firsttechfed.com/FTFCUMemWs', 'OSI2MRMcurrBalanceWebservices'};
public OSI2MRMcurrBalanceWebservices.CServReturn IsAlive(String cuid,String cuidp) {
OSI2MRMcurrBalanceWebservices.IsAlive_element request_x = new OSI2MRMcurrBalanceWebservices.IsAlive_element();
OSI2MRMcurrBalanceWebservices.IsAliveResponse_element response_x;
request_x.cuid = cuid;
request_x.cuidp = cuidp;
Map<String, OSI2MRMcurrBalanceWebservices.IsAliveResponse_element> response_map_x = new Map<String, OSI2MRMcurrBalanceWebservices.IsAliveResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://#######.com/FTFCUMemWs/IsAlive',
'http://#######.com/FTFCUMemWs',
'IsAlive',
'http://#######.com/FTFCUMemWs',
'IsAliveResponse',
'OSI2MRMcurrBalanceWebservices.IsAliveResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.IsAliveResult;
}
public OSI2MRMcurrBalanceWebservices.AccountBalances GetAccountBalances(String strUid,String strPwd,String IdTypCd,String Id) {
OSI2MRMcurrBalanceWebservices.GetAccountBalances_element request_x = new OSI2MRMcurrBalanceWebservices.GetAccountBalances_element();
OSI2MRMcurrBalanceWebservices.GetAccountBalancesResponse_element response_x;
request_x.strUid = strUid;
request_x.strPwd = strPwd;
request_x.IdTypCd = IdTypCd;
request_x.Id = Id;
Map<String, OSI2MRMcurrBalanceWebservices.GetAccountBalancesResponse_element> response_map_x = new Map<String, OSI2MRMcurrBalanceWebservices.GetAccountBalancesResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://#######.com/FTFCUMemWs/GetAccountBalances',
'http://#######.com/FTFCUMemWs',
'GetAccountBalances',
'http://#######.com/FTFCUMemWs',
'GetAccountBalancesResponse',
'OSI2MRMcurrBalanceWebservices.GetAccountBalancesResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.AccountBalances;
}
}
public class GetAccountBalances_element {
public String strUid;
public String strPwd;
public String IdTypCd;
public String Id;
private String[] strUid_type_info = new String[]{'strUid','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] strPwd_type_info = new String[]{'strPwd','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] IdTypCd_type_info = new String[]{'IdTypCd','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] Id_type_info = new String[]{'Id','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://#######.com/FTFCUMemWs','true','false'};
private String[] field_order_type_info = new String[]{'strUid','strPwd','IdTypCd','Id'};
}
public class IsAlive_element {
public String cuid;
public String cuidp;
private String[] cuid_type_info = new String[]{'cuid','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] cuidp_type_info = new String[]{'cuidp','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://#######.com/FTFCUMemWs','true','false'};
private String[] field_order_type_info = new String[]{'cuid','cuidp'};
}
public class Account {
public OSI2MRMcurrBalanceWebservices.ArrayOfAccountRole RolesOnAcct;
public String AcctNbr;
public String MjAcctTypCd;
public String MiAcctTypCd;
public String ProductNameTx;
public String NickNameTx;
public String OpenDate_YYYYMMDD;
public Decimal CurrentBalance;
public Decimal AvailableBalance;
public String StatusCd;
public String StatusTx;
public String TaxOwnerNbrType;
public String TaxOwnerNbr;
public String TaxOwnerName;
private String[] RolesOnAcct_type_info = new String[]{'RolesOnAcct','http://#######.com/FTFCUMemWs','ArrayOfAccountRole','0','1','false'};
private String[] AcctNbr_att_info = new String[]{'AcctNbr'};
private String[] MjAcctTypCd_att_info = new String[]{'MjAcctTypCd'};
private String[] MiAcctTypCd_att_info = new String[]{'MiAcctTypCd'};
private String[] ProductNameTx_att_info = new String[]{'ProductNameTx'};
private String[] NickNameTx_att_info = new String[]{'NickNameTx'};
private String[] OpenDate_YYYYMMDD_att_info = new String[]{'OpenDate_YYYYMMDD'};
private String[] CurrentBalance_att_info = new String[]{'CurrentBalance'};
private String[] AvailableBalance_att_info = new String[]{'AvailableBalance'};
private String[] StatusCd_att_info = new String[]{'StatusCd'};
private String[] StatusTx_att_info = new String[]{'StatusTx'};
private String[] TaxOwnerNbrType_att_info = new String[]{'TaxOwnerNbrType'};
private String[] TaxOwnerNbr_att_info = new String[]{'TaxOwnerNbr'};
private String[] TaxOwnerName_att_info = new String[]{'TaxOwnerName'};
private String[] apex_schema_type_info = new String[]{'http://#######.com/FTFCUMemWs','true','false'};
private String[] field_order_type_info = new String[]{'RolesOnAcct'};
}
public class AccountRole {
public String RoleCd;
public String RoleTx;
private String[] RoleCd_att_info = new String[]{'RoleCd'};
private String[] RoleTx_att_info = new String[]{'RoleTx'};
private String[] apex_schema_type_info = new String[]{'http://#######.com/FTFCUMemWs','true','false'};
private String[] field_order_type_info = new String[]{};
}
public class ArrayOfAccount {
public OSI2MRMcurrBalanceWebservices.Account[] Account;
private String[] Account_type_info = new String[]{'Account','http://#######.com/FTFCUMemWs','Account','0','-1','true'};
private String[] apex_schema_type_info = new String[]{'http://#######.com/FTFCUMemWs','true','false'};
private String[] field_order_type_info = new String[]{'Account'};
}
public class CServReturn {
public Integer ErrorNum;
public String ErrorType;
public String Message;
public String Response;
private String[] ErrorNum_type_info = new String[]{'ErrorNum','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
private String[] ErrorType_type_info = new String[]{'ErrorType','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] Message_type_info = new String[]{'Message','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] Response_type_info = new String[]{'Response','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://#######.com/FTFCUMemWs','true','false'};
private String[] field_order_type_info = new String[]{'ErrorNum','ErrorType','Message','Response'};
}
public class AccountBalances {
public OSI2MRMcurrBalanceWebservices.ArrayOfAccount Accounts;
public Integer ErrorNumber;
public String ErrorMsg;
private String[] Accounts_type_info = new String[]{'Accounts','http://#######.com/FTFCUMemWs','ArrayOfAccount','0','1','false'};
private String[] ErrorNumber_att_info = new String[]{'ErrorNumber'};
private String[] ErrorMsg_att_info = new String[]{'ErrorMsg'};
private String[] apex_schema_type_info = new String[]{'http://#######.com/FTFCUMemWs','true','false'};
private String[] field_order_type_info = new String[]{'Accounts'};
}
public class ArrayOfAccountRole {
public OSI2MRMcurrBalanceWebservices.AccountRole[] AccountRole;
private String[] AccountRole_type_info = new String[]{'AccountRole','http://#######.com/FTFCUMemWs','AccountRole','0','-1','true'};
private String[] apex_schema_type_info = new String[]{'http://#######.com/FTFCUMemWs','true','false'};
private String[] field_order_type_info = new String[]{'AccountRole'};
}
}

 

Any kind of help is appreciated!

Thanks,

Hi,

 

Following is my code for sening email from a button on a custom object Safari__c. 

Safari__c is defined as the standard controller for the page. At the end of the code, if the mail sent is successful, I want to be able to update certain fields (Email_Flag__c and Email_Date__c) on the Safari__c object. I am defining a new Safari__c in the constructor, but I am not able to access these fields. 

How can this be done?? 

Any kind of help is greatly appreciated.

 

Thanks in advance.

 

public with sharing class SendEmailPage {

public String contactEmail1 {get; set;}
public String contactEmail2 {get; set;}
public String contactEmail3 {get; set;}
public Id AccId {get; set;}

public SendEmailPage(ApexPages.StandardController controller) {
try{

Safari__c test=new Safari__c();
test=[Select Account__c,Email_Flag__c,Email_Date__c From Safari__c Where id=:ApexPages.currentPage().getParameters().get('id')];
AccId=test.Account__c;}

catch(Exception e){
}

}
//Our collection of the class/wrapper objects attachmentwrapper
public List<attachmentwrapper> attachmentList = new List<attachmentwrapper>();

List<Attachment> selectedAttachments = new List<Attachment>();

//This method uses a simple SOQL query to return a List of Attachments
public List<attachmentwrapper> getAttachments()
{
attachmentList.clear();
for (Attachment a : [select Name from Attachment where ParentId = :ApexPages.currentPage().getParameters().get('id')])
attachmentList.add(new attachmentwrapper(a));
return attachmentList;
}
//We create a new list of Attachments that will be populated only with Attachments if they are selected
public void getselectedAttachments()
{
selectedAttachments.clear();
//We will cycle through our list of attachmentwrapper and will check to see if the selected property is set to true, if it is we add the Attachment to the selectedAttachment list
for(attachmentwrapper attwrapper : attachmentList)
{
if(attwrapper.selected == true)
{
selectedAttachments.add(attwrapper.att);
}
}
for(Attachment att: selectedAttachments) {
system.debug(att);
}
}

// This is our wrapper/container class
public class attachmentwrapper
{
public Attachment att{get; set;}
public Boolean selected {get; set;}
//This is the contructor method. When we create a new attachmentwrapper object we pass a Attachment that is set to the att property.
//We also set the selected value to false
public attachmentwrapper(Attachment a)
{
att = a;
selected = false;
}
}

public String response { get; set; }
public String body { get; set; }
public String subject { get; set; }

private final Safari__c safari;
// Create a constructor that populates the Proposal object
public Safari__c getSafari() {
return safari;
}

public PageReference sendEmail() {
// Define the email
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = ContactEmail1.split(',',0);
mail.setToAddresses(toAddresses);
mail.setTargetObjectId(UserInfo.getUserId());
//mail.setTargetObjectId('003G0000017OONf');


system.debug('List of To Contacts: '+ contactEmail1);
mail.setReplyTo('noreply@yourcompany.com');
mail.setSenderDisplayName('Your Company Name');
mail.setSubject('Your Subject Here');
mail.setPlainTextBody(body);
mail.setWhatId(ApexPages.currentPage().getParameters().get('id'));
if(ContactEmail2 !=NULL && ContactEmail2.trim() != '')
{
String[] ccaddress=ContactEmail2.split(',', 0);
mail.setCcAddresses(ccaddress);
system.debug('my cc addresses here');

}

if(ContactEmail3 !=NULL && ContactEmail3.trim() != '')
{
String[] bccaddress=ContactEmail3.split(',', 0);
mail.setBccAddresses(bccaddress);
system.debug('my cc addresses here');
}
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
getselectedAttachments();
for(Integer j = 0; j < selectedAttachments.size(); j++)
{
// Add to attachment file list
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(selectedAttachments.get(j).Name);
string sname=selectedAttachments.get(j).Name;
Attachment a =[select Attachment.Name, Attachment.Body from Attachment where Attachment.Name =: sname ];
efa.setBody(a.body);
fileAttachments.add(efa);
efa=null;
}
mail.setFileAttachments(fileAttachments);
mail.setSaveAsActivity(true);
try{
Messaging.SendEmailResult[] resultMail = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
if(resultMail[0].isSuccess())
response = 'ok sent!';
else{
response = resultMail[0].getErrors().get(0).getMessage();
}
Id id= ApexPages.currentPage().getParameters().get('id');
PageReference newPage = new PageReference('/'+id);
newPage.setRedirect(true);
return newPage;
}catch(System.EmailException ex){
response = ex.getMessage();
}
return null;
}

public pagereference cancel()
{
Id id= ApexPages.currentPage().getParameters().get('id');
PageReference newPage = new PageReference('/'+id);
newPage.setRedirect(true);
return newPage;
}

}

I have created a visual force page and controller for email functionality. The page can be called  from a button on a custom object Safari__c. This custom object has a look up with accounts. 

Whenever I send an email, I want the activity to be logged in the activity history of the custom object. So I am setting setSaveAsActivity to true in my controller along defining setTargetObjectId. I am assigning the current user id to setTargetObjectId. The To , Bcc and Cc fields have a look up on contacts.  Once,  a mail is sent, this action is also logged in the activity log of the account. But, the email recipients are not actually receiving any email.  The result mail does not have any errors and says that the email has been sent.
I tried sending the email without the setTargetObjectId, it works and the email recipients do get an email. But without setTargetObjectId, I cannot log the activity. 
Any workaround on this?? 

Hi guys! I am a new developer, and I have trouble writig test class for the following batch class. Any kind of help is greatly appreciated. Thanks in advance. 

global class batchAccountsImport implements 
             Database.Batchable<SObject>,Database.AllowsCallouts {
  
  global Database.queryLocator 
                    start(Database.BatchableContext ctx){
        return Database.getQueryLocator([select id,safariUserId__c, isActive from User where isactive = true]);
    }
    global void execute(Database.BatchableContext ctx, List<Sobject> scope){
       String url = 'http://75.24.90.133:8080/restdemo/services/webservices';
       
       List<User> sfuser = (List<User>)scope; 
       List<Account> finalAccts = new List<Account>();
       system.debug('################################################################'+sfuser.size());
       
       for(integer i=0; i<sfuser.size(); i++)
       {
          Http http1 = new Http();
          System.debug('callout 1');
          HttpRequest req1 = new HttpRequest();
          //req1.setTimeout(120000); // timeout in milliseconds
          req1.setEndpoint(url+'/customers/'+sfuser[i].safariUserId__c);
          System.debug('################'+sfuser[i].safariUserId__c );
          req1.setMethod('GET');
          HttpResponse res1 = http1.send(req1);
          String xmlContent1= res1.getbody();
          Id userid = sfuser[i].id;
          List<Account> allAccts = xmlParser(xmlContent1,userid);
          for(integer j=0; j<allAccts.size();j++)
          {
             finalAccts.add(allAccts[j]);
          }
       }
       insert finalAccts;
    }
    
          
          public List<Account> xmlParser(String strXml1,Id currentUserid)
          {
          //Log the XML content
          System.debug('########Inside XMLParser Method########');
          Dom.Document doc1 = new Dom.Document();
          doc1.load(strXml1);
               
          List<Account> NewAccts = new List<Account> ();
        
          dom.XmlNode xroot1 = doc1.getrootelement();
          dom.XmlNode [] xrec1 = xroot1.getchildelements(); //Get all Record Elements
        
          for(Dom.XMLNode child1 : xrec1) //Loop Through Records
          {
             Account acct = new Account();
 
             for (dom.XmlNode awr1 : child1.getchildren() ) {
                    
                if (awr1.getname() == 'customerName') {
                   system.debug('#####################' + awr1.gettext());
                   acct.Name = awr1.gettext();
                }

                if (awr1.getname() == 'customerAccountType') {
                   system.debug('#####################' + awr1.gettext());
                   acct.Type = awr1.gettext();
                }  
      
                if (awr1.getname() == 'customerAddress') {
                   system.debug('#####################' + awr1.gettext());
                   acct.BillingStreet = awr1.gettext();
                }
                
                if (awr1.getname() == 'customerCity') {
                   system.debug('#####################' + awr1.gettext());
                   acct.BillingCity =awr1.gettext();
                }
                    
                if (awr1.getname() == 'customerZip') {
                   system.debug('#####################' + awr1.gettext());
                   acct.BillingPostalCode = awr1.gettext();
                } 
      
                if (awr1.getname() == 'customerState') {
                   system.debug('#####################' + awr1.gettext());
                   acct.BillingState = awr1.gettext();
                }
                
                if (awr1.getname() == 'customerCountry') {
                   system.debug('#####################' + awr1.gettext());
                   acct.BillingCountry = awr1.gettext();
                }
                
                if (awr1.getname() == 'customerId') {
                   system.debug('#####################' + awr1.gettext());
                   acct.safariAccId__c = awr1.gettext();
                }
                  
                if (awr1.getname() == 'userid') {
                   system.debug('#####################' + awr1.gettext());
                   acct.ownerId = currentUserid;
                }  
                
             }
             NewAccts.add(acct);
        
          }
          //insert NewAccts;
          return NewAccts;
      }
      global void finish(Database.BatchableContext ctx){
      
         //Send an email to the User after your batch completes  
         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();  
         String[] toAddresses = new String[] {'samhita.ps@gmail.com'};  
         mail.setToAddresses(toAddresses);  
         mail.setSubject('Apex Batch Job is done');  
         mail.setPlainTextBody('The batch Apex job processed ');  
         Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
      }

 }

Hi All,

 

I am making an apex callout to an external webservice, and rendering the xml page. This works fine for small amount of data, but for data running into 200,000 records, the fetching of data has to be broken down into multiple sessions, since there is a heap size limitation. For this I should pass some input parameters in the http request object, say fetch the first 1000 records in the xml file or some kind of logic, which can keep checking for the maximum heap size and stop fetching the records once the llimit is reached. Then go back, make a new http call out to the same page, start where it left off and bring in the rest of the records. Also there is a limitation on the number of callouts in a single apex transaction. So I should also include batch apex programming for this I guess. 

To start off with all this, I should be able to pass certain parameters in the http request object - limit on the number of records that has to be fetched from the xml page, and I should pass some kind fo input, say the userid as input, so that only that respective xml page is pulled up( In this case, the particular user's accounts page comes up).

Any kind of help is greatly appreciated.

 

Thanks,

 

Hi All,

 

My organization has a custom oject, proposals__c. Each proposal has multiple pdf files attached to it, which are listed in the 'Notes and Attachments' related list. Whenever a salesforce user clicks on 'Send an Email' button from the Activity History, these attachments(for that particular proposal) should automatically be attached in the send an email visualforce page. The user should have an option to check or uncheck any of the attachments, i.e. he can send only the attachments that he would choose. Is there a way to achieve this using visualforce email templates? If no, then can I use a custom button to pull up a custom visual force page for sending emails? I should retain the rich features of the standard salesforce page in either case. Any help on how this can be acheived. I am a relatively new programmer, so some sample code or examples is greatly appreciated 

 

Thanks,

 

Hi All,

 

My organization has a custom oject, proposals. Each proposal has multiple pdf files attached to it, which are listed in the notes and attachments related list. Whenever a salesforce user clicks on 'send email' button from the activity history, these attachments should automatically be attached in the send email visualforce page. The user should have an option to check or uncheck any of the attachments, i.e. he can send only the attachments that he would choose. Is there a way to achieve this using visualforce templates or should I create a custom visual force page for this and have the send email option as a custom button? I should retain the rich features of the standard email page of the salesforce. In either case, can you please help me with some example code on how this can be achieved. 

 

Thanks,

 

I require some help customizing my application. When you click on an Attachement (in the Notes and Attachements related list on a record detail page),  an Attachment detail page opens up, where you have to click on the 'View File' to open the attachment. Is there a way, where I could open the attachment by clicking the attachment on the record detail page. (In short I want to eliminate the intermediate Attachment detail page).
 
Waiting for some reply.