• LALALA
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 34
    Replies
User-added image
I was try to write code:        quote.isSyncing == true


but the error shows:             Field is not writeable


Then I find another code, but I don't know how to use it, because I didn't find where is the 'quoteToSync.Id'

This is code:
// Begin syncing Quote with Opportunity. Same as pressing the "Start Sync" button on Quote layout
parentOpp.SyncedQuoteId = quoteToSync.Id;


Thank you anyone can give me a sample code for that, appreciate that:)
Hi, Everyone:)
I am new for salesforce, now I am doing about quote line Item.

my question is I am already get all value from another object which is I need assign those value to quote line Item, but I don't know how to assign value? I don't know what is pricebookEntryId and product2Id on quote line Item........can anybody give me some idea or sample?

Thanks you very much:)
Is anyone can help me that will be so appreciate:)

My question is: when i use 'If' my regex can grab data of city and postal code,,,,but if I use 'while' to loop those data, I can't grab any data of city and postal code, I don;t know why.......But I have to use 'while'  because in datatable have two different city and postal code,  so I need Loop,,,,please any one help me:)

this is my example code:
Pattern p9 = Pattern.compile('City\\s*(?:<[^>]+>){1,}\\s*:([^<]+)');
            Matcher m9 = p9.matcher(myHtmlText);
            string dt1;
            string City;
            string Pcode;
            string [] str;
            while(m9.find()) {
                system.debug(m9.group(1));
                dt1 = m9.group(1).replaceAll('(<[^>]*>|&nbsp;)','');
                str = dt1.split('\\,');
            }         
            //City
            city = str[0];
            
            //Postal Code
            Pcode = str[1];
Hi everybody, I have a problem on my project, because I am new, so please help me, thank you a lot:)

My problem:

I need automatically create a quote on opportyunity by trigger, and I need use some data from custom object which are from OrderFromWeb__c and Orders__c. So, once I create an order__c, will trigger an new opportunity and then according to this opportunity to create an quote.

could any one can give me a example code for this, thank you:)
trigger CreateOppFromOrder on Orders__c (after insert) {
Set<String> orderNames = new Set<String>();
    
for (Orders__c order: Trigger.new) {
    orderNames.add(order.Name); 
}
    
Map<String, OrderFromWeb__c> orderFromWebMap = new Map<String, OrderFromWeb__c>();
    
for (OrderFromWeb__c ofw: [
    select OrderNumber__c,
    PO_Number__c,
    PaymentStatus__c,
        PaymentMethod__c
    from OrderFromWeb__c
    where OrderNumber__c in :orderNames]) {
    orderFromWebMap.put(ofw.OrderNumber__c, ofw);
}

 List<Opportunity> Opps = new List<Opportunity>();

for (Orders__c order : Trigger.new) {
    OrderFromWeb__c ofw = orderFromWebMap.get(order.Name);
    Opportunity op = new Opportunity(AccountId = order.Contacts__r.Account.Name);
    if (
        ofw != null &&
        ofw.PaymentMethod__c == 'PayPal Standard') {
        op.Name = date.today() + '_W:' + Order.Name;
    } else {
        op.Name = date.today() + '_:PO' + Order.Name;
    }
    
    //PO Number
        if(ofw.PaymentMethod__c == 'PayPal Standard' && ofw.OrderNumber__c == order.Name)
        {
            op.PO_Number__c = Order.Name;
        }
    else
    {
        op.PO_Number__c = ofw.PO_Number__c;
    }
    
    //Account Name
        op.AccountId = ???????    what i write is : op.AccountId = order.Contacts__r.Account.Name   but isn't work.......

        //Stage
        op.StageName = 'Closed Won';
        
        //Close Date
        op.CloseDate = date.today();
        
    opps.add(op);
    
}
    
insert opps;
}

(see bold font in code, Please)
Because Account Name field on Opportunity is lookup field, So how can I  populate lookup data to opportunity??   thanks :)
my question is:
I have one custom obj - orderFromweb     : It include such ordernumber, paymentstatus, paymentmethod.......
I have another custom object - orders       : It only include ordernumber field, and company name field from contact  
I wanna through trigger to automatically create an opportunity but i meet some problems

In opportunity have one field is Account Name, this field is reference type, it is lookup field, it has relationship between Account and quote, so I can't get API for this field, only thing I have is AccountId, So how could I get data from account and then fill into this account name field??

Thank you:) 

thank you anyone can help me
My problem:
in quote object has a field which is Account Name, this field has a relationship with account, because Account Name don't have API, but have Id which is AccountId I can use, so I don't know how to reference date to this field in Quote....  

Thank you:) 
my question is:
I have one custom obj - orderFromweb     : It include such ordernumber, paymentstatus, paymentmethod.......
I have another custom object - orders       : It only include ordernumber, and company info from contact 
I wanna through trigger to automatically create an opportunity but i meet some problems

this is my code:

List<Opportunity> newOpp = new List<Opportunity>();
    Opportunity op = new Opportunity();
    OrderFromWeb__c ofw = [select Id, OrderNumber__c, PaymentMethod__c from OrderFromWeb__c limit 1];
    Account acc = new Account();
    
    for(Orders__c Order : Trigger.new) {
        if(ofw.PaymentMethod__c == 'PayPal Standard' && ofw.OrderNumber__c == order.Name) {
            op.Name = date.Today()+'_W:'+ Order.Name;
        }
        else {                                                                                                    
            op.Name = date.Today()+'_:PO' + Order.Name;
        }

       -----question is:  'if' conditon doesn't work, because Paymentmethod is PayPal Standard, so should be running  op.Name = date.Today()+'_W:'+ Order.Name;   but it running code in 'else',,,,,I think because system doesn't know which ofw and orders to do the comparing, so is that i set Id have problems???  I don't know,


 if(ofw.PaymentMethod__c == 'PayPal Standard' && ofw.OrderNumber__c == order.Name)
        {
            op.PO_Number__c = Order.Name;
        }
else
{
   op.PO_Number__c = ofw.PO_number__c
}
same as last one,, running 'else' not right one,,,,,why?? 


thank you anyone can help me
Hi, Please help me.

In opportunity object have a look up field which name is Account Name, but when I use trriger to automatically create opportunity, I can't find any parameter can represent Account Name this field or any API can represent Account Name look up field??  Thanks

 
My problem is when i use while for using regex to grab data from HTML table, in first loop all the data was null, and second loop get the data which is first time data.

I don't know why,,please anyone help me :)
This is my code:
global class ExtractDataFromPaypal implements Messaging.InboundEmailHandler {

    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,

    Messaging.InboundEnvelope env) {

        // Create an InboundEmailResult object for returning the result of the  

        // Apex Email Service 

        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

        try {

            // Add the email plain text into the local variable  

             string myHtmlText = '';

             myHtmlText = email.htmlBody;

            

            string rst;

            string Address;

            string a1;

            string a2;

            

            //CustomerName

             Pattern p4 = Pattern.compile('Buyer\\s*information[\\s\\S]+?<br>([\\s\\S]*?)</font>');

            Matcher m4 = p4.matcher(myHtmlText);

            if (m4.find()) {

             rst = m4.group(1).replaceAll('(<[^>]*>)','');          

            }

            

            //Physical Address

            Pattern p1 = Pattern.compile('<b>\\s*Ship-to\\s*address\\s*</b>\\s*-\\s*<font[^>]+>\\s*Confirmed([\\s\\S]*?)<br>\\s*</span>');

            Matcher m1 = p1.matcher(myHtmlText);

            if (m1.find()) {

                a1 = m1.group(1).replaceAll('(<[^>]*>)',''); 

                a2 = a1.replaceAll('&nbsp;','\t');

                Address = a2.replaceAll(rst,'');

            }

            // New PaypalRecord object to be created - set Shipping_Address__c and OrderNumber etc. to object

            // dummy values for simplicity

            PayPal_Record__c record = new PayPal_Record__c(CustomerName__c = rst, Shipping_Address__c = Address

                                                    );

            // Insert a new record

            insert record;

    

        } catch (Exception e) {

            result.success = false;

            result.message = 'Oops, I failed!' + e;

        }

        // Set the resul t to true. No need to send an email back to the user      

        // with an error message   

        result.success = true;

        // Return the result for the Apex Email Service 

        return result;

    }

}


So my problem is : when i debug this code, everything is fine, it can running successfull and all the data i grabed from email can entry in database,,,,,but when i running in real environment which i use email service,,,,,, then i will received an email and told me : 
Oops, I failed!System.StringException: No match found

why?   please give me some idea and suggestion.
Thank you anyone who can help me.....:)
I can debug my code, everything is fine, all the data I need can record into my database, and can search it......but when I running my code in the real environment, always failed!! 

can anybody tell me why? 
  • April 29, 2015
  • Like
  • 0
This is my code:
        
            myPlainText = '';
            myPlainText = email.plainTextBody;
            //CustomerName
            String myHtmlText = '';
            myHtmlText = email.htmlBody;
            string rst;
             Pattern p1 = Pattern.compile('Buyer\\s*information[\\s\\S]+?<br>([\\s\\S]*?)</font>');
            Matcher m1 = p1.matcher(myHtmlText);
            if (m1.find()) {
             rst = m1.group(1).replaceAll('(<[^>]*>)','');          
            }
           
             //OrderNumber
            Pattern p2 = Pattern.compile('Invoice ID:([\\d]{7})');
            Matcher m2 = p2.matcher(myPlainText);
            if (m2.find()) {
                system.debug(m2.group(1));          
            }
            string OrderNumber = m2.group(1);
            
            // New PaypalRecord object to be created - set Shipping_Address__c and OrderNumber etc. to object
            // dummy values for simplicity
            List<PayPal_Record__c> NeedLists = new  List<PayPal_Record__c>();
            PayPal_Record__c Pplr;
            Pplr.CustomerName__c = rst;
            Pplr.OrderNumber__c = OrderNumber;
            NeedLists.add(Pplr);
    }
}

My question: when i debug these code, only can running one of regex, which means if i grab OrderNumber successful, the CustomerName will failed.All in all, i can't successful pass these of two regex together.

I don't know why? because I test single by single is fine,,,,,but together always said no match found......
  • April 28, 2015
  • Like
  • 0
I have 2 custom object which are OrderFromWeb and PayPal Record.

my question is when Order Number in PayPal Record == Order Number in OrderFromWeb, then update Payment Status from Pending to Paid in OrderFromWeb.

my code:
trigger UpdatePaymentStatus on PayPal_Record__c (after update) {
    
    
   OrderFromWeb__c ofw;
    for(PayPal_Record__c pr: Trigger.new )
    {
         
             if(ofw.OrderNumber__c ==pr.OrderNumber__c)
            {
               ofw.PaymentStatus__c='Paid';
            }
     
    }
    
}
 
  • April 22, 2015
  • Like
  • 0
Hi, everyone. 
I just wanna know which way i can extract data from Paypal email?

Situation: my salesforce can received payment email from Paypal, and i wanna get some info from email such as Invoice number, physical address and quotes, and gather these info to create a new object(Paypal Info Record).

For now, I can use Regex to get some easy data from email like Name, Phone number and Email address, because all date in the same line, so i can use regex to catch these data.

But for physical address and quotes, these kind of data not in the same line, so i can't use regex to extract those info, maybe it can but i don't know how to.....

I saw those data is in the table in html, so is regex or any other way can get data like physical address or quotes?

All in all, i just wanna get those data from email to create custom object.......

Thank you so much someone can give me some idea or some code example for me, i am really appreciate you to do this for me:) 
  • April 22, 2015
  • Like
  • 0
I am a new for the regex, so can any good people can help me answer these question? thanks....

this is my email:

Order Number: 2000157
Date Ordered: Wednesday, May 21, 2014
http://www.ggfoee.com/orderdetails.aspx?orderid=2000157
Link to Back End Order Details   


CUSTOMER ROLE: Parent 
PAYMENT METHOD: PayPal Standard 
PAYMENT STATUS: Pending 
PO URL:  No Purchase Order File Uploaded 
PO  #: 
COUPON CODE:  No coupon used 
No Comment or Instructions Given
Billing Address
Name: lacy mason
Company: Mason Tool & Engineering Ltd
Address: Unit 8/ 66 Hobill Ave,
Wiri
City: Auckland, 2241
State/Province: North Island, Ireland
Phone: 021735562


My question is:
How to use regex get those info?: Date ordered, Payment Method, Payment Status, Name, company name, Address and Phone number.
you don't need answer all, just answer what you know it. thank you again...:)
  • April 19, 2015
  • Like
  • 0
this is my code:
  String myPlainText= 'CompanyName: Heodo Order Number: 2000157 Date Ordered: Wednesday, May 21, 2014 City: Auckland, 2241 State/Province: North Island, New Zealand Phone: 021735562';
  
      Pattern p=Pattern.compile('Order Number: ([\\d]{7})'); 

      Matcher m = p.matcher(myPlainText);
      if(m.matches())
      {
        system.debug(m.group(1));          
      }      
      
Decimal Ordernum = Decimal.valueOf(m.group(1));
      OrderRecord__c record = new OrderRecord__c(CustomerEmail__c = email.fromAddress, CustomerName__c='NINI',
        OrderNumber__c =Ordernum);

 insert record;  

my qusetion is:
i wanna get a value which is 2000157 from m.group(1). but i can't.
i don't know where have problems in my code, could you tell me and give me a right answer?
i am so appriciate!!
  • April 17, 2015
  • Like
  • 0
Hi, i have a problem about regex, i spend lots of time on it but still didn't solve it. please any one can answer my question.

this is my part of code:
 try{
    String myPlainText= 'Order Number: 2000157 Date Ordered: Wednesday, May 21, 2014 City: Auckland, 2241 State/Province: North Island, New Zealand Phone: 021735562';
  
      Pattern p=Pattern.compile('(?=:)*\\d{7}'); 

      Matcher m = p.matcher(myPlainText);
      if(m.matches())
      {
        system.debug(m.group(1));          
      }      
      // New orderRecord object to be created - set CustomerEmail__c and OrderNumber__c to
      OrderRecord__c record = new OrderRecord__c(CustomerEmail__c = email.fromAddress, CustomerName__c='NINI',
        OrderNumber__c =Integer.valueOf(m.group(1)));

 insert record;  


problems: i use this code to try to extract some data from email, but failed lots of time.
I wanna use regex to extract 2000157 which is order number. but i think my regex are incorrect, so could you help me to fix it? and i can't get value of m.group(1);     
  • April 16, 2015
  • Like
  • 0
User-added image
I was try to write code:        quote.isSyncing == true


but the error shows:             Field is not writeable


Then I find another code, but I don't know how to use it, because I didn't find where is the 'quoteToSync.Id'

This is code:
// Begin syncing Quote with Opportunity. Same as pressing the "Start Sync" button on Quote layout
parentOpp.SyncedQuoteId = quoteToSync.Id;


Thank you anyone can give me a sample code for that, appreciate that:)
Hi, Everyone:)
I am new for salesforce, now I am doing about quote line Item.

my question is I am already get all value from another object which is I need assign those value to quote line Item, but I don't know how to assign value? I don't know what is pricebookEntryId and product2Id on quote line Item........can anybody give me some idea or sample?

Thanks you very much:)
trigger CreateOppFromOrder on Orders__c (after insert) {
Set<String> orderNames = new Set<String>();
    
for (Orders__c order: Trigger.new) {
    orderNames.add(order.Name); 
}
    
Map<String, OrderFromWeb__c> orderFromWebMap = new Map<String, OrderFromWeb__c>();
    
for (OrderFromWeb__c ofw: [
    select OrderNumber__c,
    PO_Number__c,
    PaymentStatus__c,
        PaymentMethod__c
    from OrderFromWeb__c
    where OrderNumber__c in :orderNames]) {
    orderFromWebMap.put(ofw.OrderNumber__c, ofw);
}

 List<Opportunity> Opps = new List<Opportunity>();

for (Orders__c order : Trigger.new) {
    OrderFromWeb__c ofw = orderFromWebMap.get(order.Name);
    Opportunity op = new Opportunity(AccountId = order.Contacts__r.Account.Name);
    if (
        ofw != null &&
        ofw.PaymentMethod__c == 'PayPal Standard') {
        op.Name = date.today() + '_W:' + Order.Name;
    } else {
        op.Name = date.today() + '_:PO' + Order.Name;
    }
    
    //PO Number
        if(ofw.PaymentMethod__c == 'PayPal Standard' && ofw.OrderNumber__c == order.Name)
        {
            op.PO_Number__c = Order.Name;
        }
    else
    {
        op.PO_Number__c = ofw.PO_Number__c;
    }
    
    //Account Name
        op.AccountId = ???????    what i write is : op.AccountId = order.Contacts__r.Account.Name   but isn't work.......

        //Stage
        op.StageName = 'Closed Won';
        
        //Close Date
        op.CloseDate = date.today();
        
    opps.add(op);
    
}
    
insert opps;
}

(see bold font in code, Please)
Because Account Name field on Opportunity is lookup field, So how can I  populate lookup data to opportunity??   thanks :)
my question is:
I have one custom obj - orderFromweb     : It include such ordernumber, paymentstatus, paymentmethod.......
I have another custom object - orders       : It only include ordernumber, and company info from contact 
I wanna through trigger to automatically create an opportunity but i meet some problems

this is my code:

List<Opportunity> newOpp = new List<Opportunity>();
    Opportunity op = new Opportunity();
    OrderFromWeb__c ofw = [select Id, OrderNumber__c, PaymentMethod__c from OrderFromWeb__c limit 1];
    Account acc = new Account();
    
    for(Orders__c Order : Trigger.new) {
        if(ofw.PaymentMethod__c == 'PayPal Standard' && ofw.OrderNumber__c == order.Name) {
            op.Name = date.Today()+'_W:'+ Order.Name;
        }
        else {                                                                                                    
            op.Name = date.Today()+'_:PO' + Order.Name;
        }

       -----question is:  'if' conditon doesn't work, because Paymentmethod is PayPal Standard, so should be running  op.Name = date.Today()+'_W:'+ Order.Name;   but it running code in 'else',,,,,I think because system doesn't know which ofw and orders to do the comparing, so is that i set Id have problems???  I don't know,


 if(ofw.PaymentMethod__c == 'PayPal Standard' && ofw.OrderNumber__c == order.Name)
        {
            op.PO_Number__c = Order.Name;
        }
else
{
   op.PO_Number__c = ofw.PO_number__c
}
same as last one,, running 'else' not right one,,,,,why?? 


thank you anyone can help me