• Vaclav Lukasek
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 12
    Replies

I sent notes about Email Template editor create improper data due inserting bad values to merged fields like:
{!Case.Id} became <span>{!</span>Case.Id<span>}</span>
this situation was not fixed but i load EmailTemplate.HtmlValue from different source, but now it crash on
HTML Value: The HTML Email Content contains improperly formatted merge fields. Please check the format of all the merge fields to ensure they start with {! and end with }.

inserted html was pasted from word and reduced html value cause this failure is

<table border="0" cellpadding="5" cellspacing="5" style="height:400px; width:550px">
    <tbody>
        <tr>
            <td style="background-color:#FFFFFF"><!--[if gte mso 9]><xml>
 <w:WordDocument>
 </w:WordDocument>
</xml><![endif]--><!--[endif]----><!--[if gte mso 10]>

<![endif]--></td>
        </tr>
    </tbody>
</table>

when is create Account in runAs block and when I set Account.ParentId to some account, it fails on INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY
runAs user has System administrator profile
Account sharing rule for Parent Account contain runAs user with read/write access
triggers are empty
when I dont set ParentId, test pass
when I dont use system.runAs, test pass
 
system.debug([Select COUNT() from XXX__c]);

will raise:
FATAL_ERROR|System.LimitException: Too many query rows: 50001
I have same code uplodade by version 28 a new version (33) of Force.com ide
new version implements special chars bad way:
following sample is not working due all special chars are missinterpreted
 
map<String, String> EscapeList = new map<String, String>{
'&ndash;' => '–',
'&#8226;' => '•',// middle dot, bullet
'&euro;' => '€',
'&nbsp;' => ' ',
};
String val = '€ •';
for (String el:EscapeList.keySet()){
   val = val.replace(EscapeList.get(el), el);
}
Process of synchonization will stay in endless loop
... Deploynig components .. Deploy status: In progress(1/1) (last checked: xxx) ... Polling sserver ... Requst Status: Pending ...
Its caused because Page is loaded from different domain:
Sample I loaded page:
https://zoom--sandbox1.cs15.my.salesforce.com/
But component with visual page contains https://zoom--sandbox1--c.cs15.visual.force.com/apex/
And because first domain contains 'my' and second one 'visual', it will be killed by Browser as Crossdomain scripting
I also like to know some workaround
Migration
update suds client changed results, but i didnt find out changes in request

BEFORE

DEBUG 2014-05-16 13:09:04,033 client 8880 6140 sending to (https://zoom--sandbox1.cs15.my.salesforce.com/services/Soap/c/30.0/00De0000005NbBW/0DFe00000008PA7)
message:
<SOAP-ENV:Envelope xmlns:ns0="urn:enterprise.soap.sforce.com" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:enterprise.soap
.sforce.com" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
      <tns:SessionHeader>
         <tns:sessionId>00De0000005NbBW!ASAAQDb2eDhz1pVMIUCaXWqH.iBcHUgBW9EZSpM7Ei6PbNqiVZ3.xX36oY8330fczoegr7dDCA1u42rDvoUqK6Z6nLRyvfTV</tns:sessionId>
      </tns:SessionHeader>
   </SOAP-ENV:Header>
   <ns1:Body>
      <ns0:create>
         <sObjects xsi:type="ens:CaseComment">
            <Id xsi:nil="true"/>
            <CreatedById>035e0000000Lf2uAAC</CreatedById>
            <CommentBody>abc</CommentBody>
            <IsPublished>True</IsPublished>
            <ParentId>500e0000002glCkAAI</ParentId>
         </sObjects>
      </ns0:create>
   </ns1:Body>
</SOAP-ENV:Envelope>
DEBUG 2014-05-16 13:09:04,036 client 8880 6140 headers = {'SOAPAction': u'""', 'Content-Type': 'text/xml', 'User-Agent': 'Salesforce/Python Toolkit/0.1.3'}
DEBUG 2014-05-16 13:09:06,444 client 8880 6140 http succeeded:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com"><soapenv:Header><LimitInfoHeader><limitInfo><cu
rrent>320</current><limit>100000</limit><type>API REQUESTS</type></limitInfo></LimitInfoHeader></soapenv:Header><soapenv:Body><createResponse><result><id>00ae000000109vaAAA</id><success>true</success>
</result></createResponse></soapenv:Body></soapenv:Envelope>

AFTER

DEBUG 2014-05-16 13:03:05,871 client 3416 7844 sending to (https://zoom--sandbox1.cs15.my.salesforce.com/services/Soap/c/30.0/00De0000005NbBW/0DFe00000008PA7)
message:

<SOAP-ENV:Envelope xmlns:ns0="urn:enterprise.soap.sforce.com" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:enterprise.soap
.sforce.com" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
      <tns:SessionHeader>
         <tns:sessionId>00De0000005NbBW!ASAAQDb2eDhz1pVMIUCaXWqH.iBcHUgBW9EZSpM7Ei6PbNqiVZ3.xX36oY8330fczoegr7dDCA1u42rDvoUqK6Z6nLRyvfTV</tns:sessionId>
      </tns:SessionHeader>
   </SOAP-ENV:Header>
   <ns1:Body>
      <ns0:create>
         <sObjects xsi:type="ens:CaseComment">
            <Id xsi:nil="true"/>
            <CreatedById>035e0000000Lf2uAAC</CreatedById>
            <CommentBody>abc</CommentBody>
            <IsPublished>True</IsPublished>
            <ParentId>500e0000002glCkAAI</ParentId>
         </sObjects>
      </ns0:create>
   </ns1:Body>
</SOAP-ENV:Envelope>
DEBUG 2014-05-16 13:03:05,874 client 3416 7844 headers = {'SOAPAction': '""', 'Content-Type': 'text/xml', 'User-Agent': 'Salesforce/Python Toolkit/0.1.3'}
DEBUG 2014-05-16 13:03:06,727 client 3416 7844 HTTP failed - 500 - Server Error:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLS
chema-instance"><soapenv:Body><soapenv:Fault><faultcode>sf:INVALID_TYPE</faultcode><faultstring>INVALID_TYPE: Must send a concrete entity type.</faultstring><detail><sf:InvalidSObjectFault xsi:type="s
f:InvalidSObjectFault"><sf:exceptionCode>INVALID_TYPE</sf:exceptionCode><sf:exceptionMessage>Must send a concrete entity type.</sf:exceptionMessage><sf:row>-1</sf:row><sf:column>-1</sf:column></sf:Inv
alidSObjectFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>

I sent notes about Email Template editor create improper data due inserting bad values to merged fields like:
{!Case.Id} became <span>{!</span>Case.Id<span>}</span>
this situation was not fixed but i load EmailTemplate.HtmlValue from different source, but now it crash on
HTML Value: The HTML Email Content contains improperly formatted merge fields. Please check the format of all the merge fields to ensure they start with {! and end with }.

inserted html was pasted from word and reduced html value cause this failure is

<table border="0" cellpadding="5" cellspacing="5" style="height:400px; width:550px">
    <tbody>
        <tr>
            <td style="background-color:#FFFFFF"><!--[if gte mso 9]><xml>
 <w:WordDocument>
 </w:WordDocument>
</xml><![endif]--><!--[endif]----><!--[if gte mso 10]>

<![endif]--></td>
        </tr>
    </tbody>
</table>

when is create Account in runAs block and when I set Account.ParentId to some account, it fails on INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY
runAs user has System administrator profile
Account sharing rule for Parent Account contain runAs user with read/write access
triggers are empty
when I dont set ParentId, test pass
when I dont use system.runAs, test pass
 
here is my controller class 
public without sharing class UpdateList {
    list<order> selectorder;
    String quoteId {set; get;}
    String selectedOrderId {set; get;}
    public List<Order> selectedOrders {set; get;}
    public Boolean orderUpdated {set; get;}    
    public UpdateList(){
        quoteId = ApexPages.currentPage().getParameters().get('quoteID');
        orderUpdated = false;
    } 
    public PageReference selectOrder(){
        selectedOrderId = ApexPages.currentPage().getParameters().get('ordersRadio');
        selectedOrders = [select Id, OrderNumber, Status from Order where id=:selectedOrderId];
        return null;
    }    
    public list<Order> getorderslist()
    {
        List<order> allords=[select Id,Ordernumber,Status from Order where quoteId=:quoteId];
        return allords;
    }    
    //call this method to update order, and copy all quote line items from quote
    public PageReference updateOrder(){     
        //get selected orderId from the list   
        selectedOrderId = ApexPages.currentPage().getParameters().get('ordersRadio');
        //get quote line items using the quoteId
        List<OrderItem> orderLines = new List<OrderItem>(); 
        for(QuoteLineItem qLine : [SELECT Id, QuoteId, PricebookEntryId, Quantity, UnitPrice, Discount, Description, ServiceDate, 
                                   Product2Id, SortOrder, ListPrice, Subtotal, TotalPrice FROM QuoteLineItem where QuoteId=:quoteId]){
            OrderItem oLine         = new OrderItem();
            oLine.OrderId           = selectedOrderId;
            oLine.PricebookEntryId  = qLine.PricebookEntryId;
            oLine.Quantity          = qLine.Quantity;
            oLine.UnitPrice         = qLine.UnitPrice;
            oLine.Description       = qLine.Description;
            oLine.ServiceDate       = qLine.ServiceDate;
            orderLines.add(oLine);
        } 
        insert orderLines;       
        orderUpdated = true;
         ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Record updated Successfully.Thank you!'));
        return null;       
    }    
}


here my test class
@istest (seeAllData=true)
private without sharing class TestUpdateList{
    
    Private static Account a;
    Private static Contact c;
    Private static Opportunity opp;
    Private static Quote q;
    Private static QuoteLineItem Qli;
    private static Order o;
    Static {    
        // Creating the data for Account,Contact,Opportunity,Quote and Order.
        
        a=new Account(Name='test1',Phone='9458383336');   // creating account with only mandatory Fields
        insert a;
        c = new Contact(LastName='Test',AccountId=a.Id);  // creating contact with only mandatory Fields
        insert c;
        
        // creating opportunity with only mandatory Fields
        opp = new Opportunity(Name='Test Opp',AccountId=a.Id,StageName='closedwon',CloseDate=Date.Today());
        insert opp;
        
        Pricebook2 stdPb = [select Id from Pricebook2 where isStandard=true limit 1];
        
        Product2 p = new product2(name='test',family='test',productcode='12345');
        insert p;
        System.debug('### p:'+p);
        
        PricebookEntry pbe = new PricebookEntry(pricebook2id=stdPb.id, product2id=p.id,
                                                unitprice=1.0, isActive=true,UseStandardPrice=false);
        insert pbe;
        
        // Creating Quote with only mandatory Fields
        q=new Quote(Name='testquote',opportunityId=opp.Id, pricebook2id=stdPb.id);
        insert q;
        // Creating Quote Line Items PricebookEntryId, Product2Id
        qli=new QuoteLineItem(QuoteId=q.Id,pricebookentryid=pbe.id, Quantity=12,UnitPrice=1500,Discount=0,Description='nothing',ServiceDate=system.today());
        insert qli;
        // Creating Order with mandatory Fields 
        o=new Order(AccountId=a.Id,Name='test',status='draft',EffectiveDate=system.today());
        insert o;                    
    }  
    // retreiving the order record and  working fine 25% code coverage with this method.
    Static TestMethod void Testgetorderslist(){
        Test.StartTest();

        PageReference pageRef=page.PrevOrder;
        pageRef.getParameters().put('quoteID',q.Id);
        Test.SetCurrentPageReference(pageRef);

        UpdateList ul=new UpdateList();
        List<order> orderList = ul.getorderslist();

        pageRef.getParameters().put('selectOrder',o.Id);
        ul.SelectOrder();
        ul.updateOrder();

        system.debug('test result ='+ orderList);
        system.assertEquals(orderList.size(),1);

        Test.StopTest();
    }
   
    Static TestMethod void TestselectOrder(){
        Test.StartTest();
        PageReference pageRef=page.PrevOrder;
        Test.SetCurrentPageReference(pageRef);
        ApexPages.currentPage().getParameters().put('ordersRadio',o.Id);   
        ApexPages.StandardController sc = new ApexPages.standardController(o);              
        UpdateList controller=new UpdateList();   
        controller.SelectOrder();  
        controller.UpdateOrder();
        Test.StopTest();    
    }    
}

i am getting the above error when i run my test class.
how to solve this?
 
system.debug([Select COUNT() from XXX__c]);

will raise:
FATAL_ERROR|System.LimitException: Too many query rows: 50001
I have same code uplodade by version 28 a new version (33) of Force.com ide
new version implements special chars bad way:
following sample is not working due all special chars are missinterpreted
 
map<String, String> EscapeList = new map<String, String>{
'&ndash;' => '–',
'&#8226;' => '•',// middle dot, bullet
'&euro;' => '€',
'&nbsp;' => ' ',
};
String val = '€ •';
for (String el:EscapeList.keySet()){
   val = val.replace(EscapeList.get(el), el);
}
Process of synchonization will stay in endless loop
... Deploynig components .. Deploy status: In progress(1/1) (last checked: xxx) ... Polling sserver ... Requst Status: Pending ...
Its caused because Page is loaded from different domain:
Sample I loaded page:
https://zoom--sandbox1.cs15.my.salesforce.com/
But component with visual page contains https://zoom--sandbox1--c.cs15.visual.force.com/apex/
And because first domain contains 'my' and second one 'visual', it will be killed by Browser as Crossdomain scripting
I also like to know some workaround

I have a Hierarchy Custom setting with one field IsProcessed.

 

My batch apex will run only when the value of  IsProcessed is true. After processing I need to update the value to false. I doubt whether it is possible.

 

Is there a way I can update a custom setting field value using apex.

 

Appreciate your help.