• Roman Vasetskiy
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
Developers,

we have a oracle and Sf integration through SOA. we have two custom objects called orders and Customer in SF.. Orders will be updated for Every 15 minutes through SOA. also we have a lookup relation from orders to Customer. 

1Question : 

when Orders were updated if there is no customer ID ( we use customer id as forgien key )  found we are getting an error . says Foreign key external ID not found ..  how can i resolve this. 

2Question : 

if i write a trigger to update Customer id with the value i am getting also it asks first name and last name which is not in Salesforce .. so first time insert as unknown and second time upsert the values. , or is there any other way to resolve this?

really apprciate your help

Thanks
Beat.

 
I have a Visualforce page that takes a request and then sends its result by email.
At present, the request is fixed, but I want to use any request.
So goes the question: how do this part to be dynamic:

for(Case a: (List<Case>)database.query(caseTT))
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}


Thank you!

The codes:

PAGE VISUALFORCE::::
<apex:page controller="AAAACSV">
    <style type="text/css">
        .classeRequete { width: 600px; }
        .classeMail { width: 400px; }
    </style>   
  <apex:form >
  <apex:PageBlock >
    Request :&nbsp;&nbsp;<apex:inputText styleClass="classeRequete" value="{!caseTT}"/><br /><br />
    <apex:commandButton value="Valider" action="{!planifier}"/> <br/><br/>
    <apex:commandButton value="Effacer"/> <br/><br/>
  </apex:PageBlock>
  </apex:form>
</apex:page>


CLASS APEX::::
global class AAAACSV implements System.Schedulable {
public string caseTT {get; set;}
  
global void execute(SchedulableContext sc) {
planifier();
}

public void planifier(){
String query = caseTT;
String premier=query.substringAfter('select');     
premier=  premier.substringBefore('from');
string titre= premier+'\n';
string contenuCSV = titre;

for(Case a: (List<Case>)database.query(caseTT))
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}

String lignes = contenuCSV;
List<String> parts = lignes.split('\n');
integer lineNumber = parts.size();

Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(contenuCSV);
nomFichierCSV = 'Closed_'+Date.today().format()+'.csv';
csvPJ.setFileName(nomFichierCSV);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {'mail@mail.com'};
String subject = 'Rreports';
email.setSubject(subject);
email.setToAddresses(adressMail);

email.setPlainTextBody('Mail....);
                        
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); 

}
}