• Tadeas B
  • NEWBIE
  • 65 Points
  • Member since 2016

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
Hello,

An account has a account history at the bottom of the page laypout.  how is it possible to have it for a custom object created.
  • January 20, 2016
  • Like
  • 0
Hi Everyone,
         I have written a @HTTP Post method which works fine. I need a sample code to write it's test class . Can anyone  please help me with this? My test method is giving an error saying that method doPost() does not exist (second last line).

Apex Code:

@RestResource(urlMapping='/v1/cans/*')
global with sharing class MyRestResource {
  @HttpPost
    global static DocWrapper doPost(String Description, String ParentId, String FilePathname, String Name, String Type) {
        DocWrapper response=new DocWrapper();
        Document__c doc= new Document__c();
        doc.Doc_Name__c=Name;
        doc.Type__c=Type;
        doc.CAN__c=ParentId;
        doc.Link__c=FilePathname;
        doc.Description__c=Description;
        insert doc;
        response.message='Doc Inserted';
        return response;
        
     }
       global class DocWrapper {          
          public String message;
     }
}

Test Method:


static testMethod void testDoPost(){
        
        RestRequest req = new RestRequest(); 
        RestResponse res = new RestResponse();
        
        RecordType RecType = [Select Id From RecordType  Where SobjectType = 'CAN__c' and Name = 'CAN Fed'];    
        CAN__c cf = new CAN__c (Name='Test CAN 1',RecordTypeId=RecType.Id);
        insert cf;
        String CanId=cf.id;
        
        req.requestURI = '/services/apexrest/v1/cans/';  
        req.addParameter('Description', '0000000');
        req.addParameter('ParentId',CanId);
        req.addParameter('FilePathname', 'www.google.com');
        req.addParameter('Name', '1wer2547');
        req.addParameter('Type', '1wer2547');

        req.httpMethod = 'POST';
        RestContext.request = req;
        RestContext.response = res;
        
        Test.startTest();
        MyRestResource.DocWrapper results = MyRestResource.doPost();
        Test.stopTest();
        

    }
Hello,

I'm trying to use OpenSpace in Salesforce with their given source:
 
<script type="text/javascript" src="http://www.openspace.ordnancesurvey.co.uk/osmapapi/openspace.js?key=BA08531D8339984EE0405F0AC86026A9"></script> 

but when I run the vf page gives me the following error:

"Mixed Content: The page at 'https://c.eu5.visual.force.com/apex/TestOSMaps' was loaded over HTTPS, but requested an insecure script 'http://openspace.ordnancesurvey.co.uk/osmapapi/openspace.js?key=BA08531D8339984EE0405F0AC86026A9'. This request has been blocked; the content must be served over HTTPS."

I've tried to change from http to https but it doesn't work.

Is there a way to solve this?

Thanks
Hello,

An account has a account history at the bottom of the page laypout.  how is it possible to have it for a custom object created.
  • January 20, 2016
  • Like
  • 0
Hi Everyone,
         I have written a @HTTP Post method which works fine. I need a sample code to write it's test class . Can anyone  please help me with this? My test method is giving an error saying that method doPost() does not exist (second last line).

Apex Code:

@RestResource(urlMapping='/v1/cans/*')
global with sharing class MyRestResource {
  @HttpPost
    global static DocWrapper doPost(String Description, String ParentId, String FilePathname, String Name, String Type) {
        DocWrapper response=new DocWrapper();
        Document__c doc= new Document__c();
        doc.Doc_Name__c=Name;
        doc.Type__c=Type;
        doc.CAN__c=ParentId;
        doc.Link__c=FilePathname;
        doc.Description__c=Description;
        insert doc;
        response.message='Doc Inserted';
        return response;
        
     }
       global class DocWrapper {          
          public String message;
     }
}

Test Method:


static testMethod void testDoPost(){
        
        RestRequest req = new RestRequest(); 
        RestResponse res = new RestResponse();
        
        RecordType RecType = [Select Id From RecordType  Where SobjectType = 'CAN__c' and Name = 'CAN Fed'];    
        CAN__c cf = new CAN__c (Name='Test CAN 1',RecordTypeId=RecType.Id);
        insert cf;
        String CanId=cf.id;
        
        req.requestURI = '/services/apexrest/v1/cans/';  
        req.addParameter('Description', '0000000');
        req.addParameter('ParentId',CanId);
        req.addParameter('FilePathname', 'www.google.com');
        req.addParameter('Name', '1wer2547');
        req.addParameter('Type', '1wer2547');

        req.httpMethod = 'POST';
        RestContext.request = req;
        RestContext.response = res;
        
        Test.startTest();
        MyRestResource.DocWrapper results = MyRestResource.doPost();
        Test.stopTest();
        

    }
HI All,

I have a text field(Status__C) in Custom object(Communication__c). This field is getting updated from external service.
My requirement is, that whenever Status__c value equals to FAILED, then the image should be displayed with this status, in the same field only.
Or the color of text should be Red.
I don't want to use any VF page for that.
Any idea how to achieve this by configuration.

Thanks in advance,
Manav
I use simple jquery code in vf page but its not work please help.

<apex:page standardController="Account" tabStyle="Account" sidebar="false">
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <script>
            $(document).ready(function()
            {
                 $("#Button").click(function()
                 {
                      $("#nm").hide();
                 });
           });
        </script>
    </head>
     
     <apex:form >   
     <apex:pageBlock title="Jquery Ex">
         <apex:outputText value="{!account.name}" label="NAME" id="nm"/>
        <apex:pageBlockButtons >
                <apex:commandButton id="Button" value="Jquery"/>
            </apex:pageBlockButtons>
     </apex:pageBlock>
     </apex:form>
</apex:page>

This is my code.
The requirement is to show the UK parliamentary constituency based on the postcode of an account.  Using a custom object to store the constituency for each postcode would result in pretty close to 1 million rows.

1 - Can anyone share experience of working with an object on this scale?  What kind of performance impact may be expected?  Any data loading challenges?

2 - It feels like Apex would be needed to populate an Account 'Constituency' field based on the postcode.  Anyone have any alternative suggestions?

There are other considerations such as the impact on the data volume usage and what happens when boundaries are changed, but just looking to see if this is worth considering further.

Many Thanks,
Mike.