• juan.cardona
  • NEWBIE
  • 0 Points
  • Member since 2012
  • Electronic Engineer
  • Tata Consultancy Services

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

After having most test failed suddenly for no apparent reason, we found that the culprit was that a field we were using to search for a special user was changed to be unique. 

User[] users = [select id from User where Unique_Field___c = :'Special' limit 1];
System.assert(users.size()>0, 'Missing Special user configuration.');

 If I run the code in a test method, I get 'Missing Special user configuration.' assert exception. If I run it in a developer console, it runs without the assert triggering.

Any ideas why is this? Is it a bug or feature? Is it documented anywhere?

Hello ,

              I recently started developing in Apex with .net background and I am looking for insight to solve the below problem.

 

I have 30K carriers(Account) objects and need to update them on a nightly basis from a webservice (like insurance etc ).

 

I was able to successfully implement the webservice and update a single account but now I have to do that in a batch

 

Class UpdateService-- Take AccountObject and gets the latest information and does a DML.

 

ClassBatchAccounts--Gets the list of all Accounts and pass each account to above class

 

ClasScheduleBatch--Call above BatchAccounts(every day inthe morning).

 

When i implement this i am getting too many callouts.

 

I need to call webservice for each account so how can i do that in ApexBatch?

 

Any insight would be helpfull...

 

 

How do i resolve this...This is my code...I am sending an XML to an endpoint n number of times(its in a for loop)...Cant i do that?

public PageReference saveUsers() {
String[] listOfSelectedUsers = getUsers();
String domainId = System.currentPageReference().getParameters().get('ex');
for(String presentVar: listOfSelectedUsers)
{

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://84.40.30.147/cm/spws');
req.setMethod('POST');

TestExtranet__c extranet = [select Extranet_Name__c from TestExtranet__c where id = :domainId];
Lead lead = [select id,firstname,lastname,email from Lead where id = :presentVar];
String requestXML = buildXMLRequest('createUser',extranet.Extranet_Name__c,lead.id,lead.firstname,lead.lastname,lead.email);

req.setBody(requestXML);
HttpResponse res = h.send(req);
XmlStreamReader reader = res.getXmlStreamReader();
boolean errorExists = parseResponseForError(reader);
if(!errorExists)
{
Extranet_User_Mapping__c mapping = new Extranet_User_Mapping__c();
mapping.Extranet_Id__c = domainId;
mapping.Leads__c = presentVar;
insert mapping;
}else
{

}


}
PageReference userConfPage = new PageReference('/apex/userConfirmation?ex='+ System.currentPageReference().getParameters().get('ex'));
return Page.userConfirmation;
}