• Rajesh Rajesh Kumar
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 1
    Replies
Hii
"error": {
        "code": 500,
        "message": ""Cannot coerce Null (null) to String

1| 'ex1' ++ payload.uci.customer.contract.applicationId as String  ++ '.txt'
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Trace:
  at ++ (line: 1, "
    },
How it works ?
trigger RestrictContactByName on Contact (before insert, before update) {
//check contacts prior to insert or update for invalid data
For (Contact c : Trigger.New) {
if(c.LastName == 'INVALIDNAME') { //invalidname is invalid
c.AddError('The Last Name "'+c.LastName+'" is not allowed for DML');
}
}
}
HI all,
I need to write the test class for DOM XML parser. Could anyone please help me out from this

public class DomNamespaceSample 
{

    public void sendRequest(String Endpoint)
    {
        // Create the request envelope
     
        
        DOM.Document doc = new DOM.Document();
        
         List<Address__c> addr=[SELECT Company__c,Division__c,City__c,PostalCode__c FROM Address__c];
         string str1= addr[0].Company__c;
         string str2=addr[0].Division__c;
         string str3=addr[0].City__c;
         string str4=addr[0].PostalCode__c;
         List<LineItem__c> addr1=[SELECT Product__c,ExtendedPrice__c FROM LineItem__c];
         string str5=addr1[0].Product__c;
         string str6=addr1[0].ExtendedPrice__c;
         string str7=addr1[1].Product__c;
         string str8=addr1[1].ExtendedPrice__c;
        
        

        
        
        VertexAPI__c vertexConfig=VertexAPI__c.getInstance();
        string soapNS=vertexConfig.soapNS__c;
        String user=vertexConfig.UserName__c;
        string pass=vertexConfig.Password__c;
        String xsi =vertexConfig.xsi__c;
        String serviceNS=vertexConfig.serviceNS__c;
        //String soapNS = 'http://schemas.xmlsoap.org/soap/envelope/';
       // String xsi = 'urn:vertexinc:o-series:tps:8:0';
        //String serviceNS = 'http://www.w3.org/2001/XMLSchema-instance';
        
        dom.XmlNode envelope =doc.createRootElement('Envelope', soapNS, 'soapenv');
        envelope.setNamespace('urn', xsi);
        //envelope.setNamespace('xmlns', xsi);
        //envelope.setAttributeNS('urn',xsi, null);
        //envelope.setNamespace('xsi','urn:vertexinc:o-series:tps:8:0');
        
        dom.XmlNode header=envelope.addChildElement('Header', soapNS, 'soapenv');
        
        dom.XmlNode body=envelope.addChildElement('Body', soapNS,  'soapenv');
        Dom.XmlNode vertexEnvelope =body.addChildElement('urn:VertexEnvelope',soapNS,'');
        vertexEnvelope.setAttributeNS('xmlns', soapNS, xsi, null);
        //vertexEnvelope.setAttribute('xmlns',serviceNS);
        //vertexEnvelope.setNamespace('xsi','http://www.w3.org/2001/XMLSchema-instance');
        Dom.XmlNode login=vertexEnvelope.addChildElement('urn:Login', null,null);
        Dom.XmlNode uid=login.addChildElement('urn:UserName',null,null).addTextNode(user);
        Dom.XmlNode pwd=login.addChildElement('urn:Password', null,null).addTextNode(pass);
        Dom.XmlNode invoiceRequest =vertexEnvelope.addChildElement('urn:InvoiceRequest', null, null);
        invoiceRequest.setattribute('documentDate','2019-01-30');
        invoiceRequest.setattribute('transactionType','LEASE');
        
        Dom.XmlNode seller=invoiceRequest.addChildElement('urn:Seller',null,null);
        seller.addChildElement('urn:Company', null, null).addTextNode(str1);  
        seller.addChildElement('urn:Division', null, null).addTextNode(str2);
        
        // start coustomer tag
        Dom.XmlNode customer = invoiceRequest.addChildElement('urn:Customer', null, null);
        //customer.setattribute('isTaxExempt','false');
        Dom.XmlNode destination= customer.addChildElement('urn:Destination',null,null);
        Dom.XmlNode city=destination.addChildElement('urn:City',null,null).addTextNode(str3);
        Dom.XmlNode zipCode=destination.addChildElement('urn:PostalCode',null,null).addTextNode(str4);
        
        // LineItem="1"
        Dom.XmlNode lineitem1=invoiceRequest.addChildElement('urn:LineItem',null,null);
        lineitem1.setattribute('lineItemNumber','1');
        // product tag
        lineItem1.addChildElement('urn:Product',null,null).addTextNode(str5);
        lineItem1.addChildElement('urn:ExtendedPrice',null,null).addTextNode(str6);
        
        // LineItem="2"
        Dom.XmlNode lineitem2=invoiceRequest.addChildElement('urn:LineItem',null,null);
        lineitem2.setattribute('lineItemNumber','2');
        // product tag
        lineItem2.addChildElement('urn:Product',null,null).addTextNode(str7);
        lineItem2.addChildElement('urn:ExtendedPrice',null,null).addTextNode(str8);
        
         System.debug(doc.toXmlString());
        
        
        
        //string strRes=XML;
        //doc.load(strRes);
        //system.debug(strRes);
        //insert 
        
       
        //doc.load(request1);
        //request1.XMLRequest__c=doc.load(doc.toXmlString());
        //insert request1;
       
        
        // Send the request
        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint(Endpoint);
        req.setHeader('Content-Type', 'text/xml');
        req.setBodyDocument(doc);
                
        Http http=new Http();
        HttpResponse res=http.send(req);
        System.assertEquals(200,res.getStatusCode());
        //string str=res.getBody();
        system.debug(res.getBody());
  }
Hi All,
can any one help me by giving code for vfpage
1) should contain stndard controller and extension
2) one input text and command Button
on loading page the textbox should be disable and when button is clicked it should get enabled. by using javascript.

please can any one give code for this.
 
hi
i am new to salesforce platform.
Install a simple Apex class, write unit tests that achieve 100% code coverage for the class, and run your Apex tests.The Apex class to test is called 'VerifyDate', and the code is available here. Copy and paste this class into your Developer Edition via the Developer Console.
'VerifyDate' is a class which tests if a date is within a proper range, and if not will return a date that occurs at the end of the month within the range.
The unit tests must be in a separate test class called 'TestVerifyDate'.
The unit tests must cover scenarios for all lines of code included in the Apex class, resulting in 100% code coverage.
Run your test class at least once (via the Developer Console) before attempting to verify this challenge.

In the above challege i am not able to write a 'TestVerifyDate' class. I dont unsertstand how to write it for a date.
plz help..