• adityaMorgan
  • NEWBIE
  • 35 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 14
    Replies
I have a WSDL. When I parse it to genrate apex class from it, I am reciving an exception (Unsupported attributes). Also, some varibale definations are missing from the class created. Is there any tool like SOAP UI, which can generate request and response method from WSDL. Also, how to use that tool. Any help please.
I have the following code using this i can find account address on google map. But i have to find nearby hotels by using that address. How to do that? here is my code:

<apex:page standardController="Account">
 <head>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript"> 

$(document).ready(function() {

  var myOptions = {
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false
  }

  var map;
  var marker;

  var geocoder = new google.maps.Geocoder();
  var address = "{!Account.BillingStreet}, " + "{!Account.BillingCity}, " + "{!Account.BillingPostalCode}";

  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Account.Name}</b><br>{!Account.BillingStreet}<br>{!Account.BillingCity}, {!Account.BillingPostalCode}"
  });
  
  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);

        //center map
        
        map.setCenter(results[0].geometry.location);
        

        //create marker
        marker = new google.maps.Marker({
        
            position: results[i].geometry.location,
            map: map,
            title: "{!Account.Name}"
            
        });

        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });

      }

    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s billing address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  });

  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }

});
</script>

<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:250px;
  background:transparent;
}
</style>

</head>

<body>
<div id="map"></div> 
</body> 
</apex:page>

Thnaks,
Aditya
Hi,
In our org we have lot of javascript for hiding button or some other functions. As, salesforce will start removing javascript tags from homepage components our functionality will break down. We have been able to move some of the components on Visualforce Area but some components which involve complex javascript and are interacting with the entire homepage are not working as expected in Visualforce Area. Anyone please suggest me workaround for this. How to make sure that our functionality will work as expected.
Thanks.
Hi,
I am new to Chatter API. I am trying to get user info, paste a feed and comment, and update photo by using chatter API. Most of the time when I am using urls and body given in Chatter API guide i get the error massage the resource does not  exist.
Following are the URLS used by me :
1. /services/data/v32.0/chatter/users/me/photo?cropSize=240&cropX=20&cropY=20&fileId=06990000001CAQq  : dose not work on testing.
    fileId=06990000001CAQq is the Id of my contentDocument image. 

2. /services/data/v29.0/chatter/users/me   :     This usrls works when I am testing by developer console.
3. /services/data/v26.0/chatter/feeds/record/' + '00190000011tgvd' + '/feed-items   : This usrls works when I am testing by developer console.

Also for chatter feed the Url given in chatter API guide is not working.
the URL given is :
/services/data/v32.0/chatter/feed-elements?feedElementType=FeedItem&subjectId=0F9B000000000W2&text=New+post.

Kindly help.

Thanks,
Aditya 
My class is similar to this class: 

@RestResource(urlMapping='/MyRestContextExample/*')
                           
global with sharing class MyRestContextExample {

    @HttpGet
    global static Account doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId];
        return result;
    }
 
}

Test method :

public static testMethod void AttendeeTest(){
        createData();
        String contactId = [Select Id from Contact where Email= : 'testNew@test.com'].Id;
        test.startTest();
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        req.requestURI = 'https://ap1.salesforce.com/MyRestContextExample/'+contactId;
        req.httpMethod = 'GET';
        system.debug('---requestURI'+req.requestURI);  // here i am getting correct URL 
        List<Account> atndInsert = MyRestContextExample.doGet();
        test.stopTest();
    }

Above method is returning null pointer exception at line 
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
On debugging I found RestRequest req has value null so req.requestURI is throwing exception. But I am providing request uri in my test class.(req.requestURI= 'https://ap1.salesforce.com/MyRestContextExample/'+contactId;). Then how come it is null. 
Please help.

Hi,

We have around 200 users on Salesforce license out of them we want 50 users to move on Chatter Free License. I know manually we cannot change to Chatter Free License. So we have requested salesforce to change it. My question is that on changing the license we will be losing chatter posts by these users or other user on their profile page also or not? We do not want this to happen.

We are concerned about profile page only not other record pages.

 

 

   

Hi,
In our org we have lot of javascript for hiding button or some other functions. As, salesforce will start removing javascript tags from homepage components our functionality will break down. We have been able to move some of the components on Visualforce Area but some components which involve complex javascript and are interacting with the entire homepage are not working as expected in Visualforce Area. Anyone please suggest me workaround for this. How to make sure that our functionality will work as expected.
Thanks.
I have a WSDL. When I parse it to genrate apex class from it, I am reciving an exception (Unsupported attributes). Also, some varibale definations are missing from the class created. Is there any tool like SOAP UI, which can generate request and response method from WSDL. Also, how to use that tool. Any help please.
Hi,
In our org we have lot of javascript for hiding button or some other functions. As, salesforce will start removing javascript tags from homepage components our functionality will break down. We have been able to move some of the components on Visualforce Area but some components which involve complex javascript and are interacting with the entire homepage are not working as expected in Visualforce Area. Anyone please suggest me workaround for this. How to make sure that our functionality will work as expected.
Thanks.
Hi,
         My page:
--------------------

<apex:page controller="ctrollercls sidebar="false">
<apex:sectionHeader title="Account Contact Opportunity Fields"/>
<apex:form >
    <apex:pageBlock >
    <apex:pageBlockButtons location="top">
       <apex:commandButton value="Save" action="{!doSave}"/>
    </apex:pageBlockButtons>
  
    <apex:pageBlockSection title="Contact Fields" rendered="{!iFieldBoolean}">
    <apex:outputField value="{!contactObject.name}"/>
    <apex:outputField value="{!contactObject.Phone}"/>
    <apex:outputField value="{!contactObject.Fax}"/>
        </apex:pageBlockSection>
    <apex:pageBlockSection title="Opportunity Fields" rendered="{!iFieldBoolean}">
    <apex:outputField value="{!opportunityObject.Name}"/>
    <apex:outputField value="{!opportunityObject.CloseDate}"/>
    <apex:outputField value="{!opportunityObject.StageName}"/>
      </apex:pageBlockSection>
       <apex:pageBlockSection title="Account Fields" rendered="{!iFieldBoolean}">
    <apex:outputField value="{!contactObject.Account.name}"/>
        <apex:outputField value="{!contactObject.Account.phone}"/>
   
     </apex:pageBlockSection>
  
    </apex:pageBlock>
</apex:form>
</apex:page>

Controller:
-------------
public class Controllercls{


     public Boolean isBoolean { get; set; }
    
     public List<Opportunity> opportunityObject{get; set;}
   
     public ID cid{get; set;}
           
     public Contact contactObject{get; set;}
    
        public Controllercls()
        {
       
       
        opportunityObject=new List<Opportunity>();
                 if(ApexPages.currentPage().getParameters().get('conid') != NULL)
                 {
                cid = ApexPages.currentPage().getParameters().get('conid');
                }
       
        contactObject=[SELECT id,Name,AccountId,Account.Name,Account.Phone,Fax,Phone FROM Contact WHERE id = :cid];
       
      
         opportunityObject=[Select Id, (Select Id, Contact.Name,CloseDate,StageName From OpportunityContactRoles where  Id =:cid) From Opportunity];
       
        }
        public PageReference doSave() {
               
                try{
                                upsert(contactObject);
                                upsert(opportunityObject);
                       
                        }catch(Exception e)
                        {
                               
                        }
                        pageReference ref=new PageReference('/apex/contactAccountOpportunityFieldsPage?conid='+cid);
                return ref.setRedirect(true);
            }
      
}

help me......
Hi,
I am new to Chatter API. I am trying to get user info, paste a feed and comment, and update photo by using chatter API. Most of the time when I am using urls and body given in Chatter API guide i get the error massage the resource does not  exist.
Following are the URLS used by me :
1. /services/data/v32.0/chatter/users/me/photo?cropSize=240&cropX=20&cropY=20&fileId=06990000001CAQq  : dose not work on testing.
    fileId=06990000001CAQq is the Id of my contentDocument image. 

2. /services/data/v29.0/chatter/users/me   :     This usrls works when I am testing by developer console.
3. /services/data/v26.0/chatter/feeds/record/' + '00190000011tgvd' + '/feed-items   : This usrls works when I am testing by developer console.

Also for chatter feed the Url given in chatter API guide is not working.
the URL given is :
/services/data/v32.0/chatter/feed-elements?feedElementType=FeedItem&subjectId=0F9B000000000W2&text=New+post.

Kindly help.

Thanks,
Aditya 
My class is similar to this class: 

@RestResource(urlMapping='/MyRestContextExample/*')
                           
global with sharing class MyRestContextExample {

    @HttpGet
    global static Account doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId];
        return result;
    }
 
}

Test method :

public static testMethod void AttendeeTest(){
        createData();
        String contactId = [Select Id from Contact where Email= : 'testNew@test.com'].Id;
        test.startTest();
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        req.requestURI = 'https://ap1.salesforce.com/MyRestContextExample/'+contactId;
        req.httpMethod = 'GET';
        system.debug('---requestURI'+req.requestURI);  // here i am getting correct URL 
        List<Account> atndInsert = MyRestContextExample.doGet();
        test.stopTest();
    }

Above method is returning null pointer exception at line 
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
On debugging I found RestRequest req has value null so req.requestURI is throwing exception. But I am providing request uri in my test class.(req.requestURI= 'https://ap1.salesforce.com/MyRestContextExample/'+contactId;). Then how come it is null. 
Please help.

i serialized a list ino JSON String.,

 

I am using HTTP Post to send that json to other end.,

 

I need to handle special characters in my JSON string,

 

Please help me.,

  • December 10, 2012
  • Like
  • 0

Hi,

 

I've created below class and want to display records in Visual source page.

 

public class JSONTest {
    
    Public string strName{get;set;}
    Public string strPrint {get;set;}
    Public List<items> itemList {get;set;}

    String jsonStr = '{"feed":{"row_count":1,"items":[{"msg":"<a class="keyword" href=http://abc.html>XYZ</a>Clicked<a class="keyword" href=http://abc.html>http://abc.html</a>","interest":"Other","whendt":"3/26/2012 6:22:49 PM"}]}}';
    
    public void PrintJSONRecords(){
    itemList = (List<items>)JSON.deserialize(jsonStr ,List<items>.class);
   }    
    
    public void submit()
    {
        PrintJSONRecords();
    }
    
    class feed {
        public Integer row_count;
        public items[] itemss;
         
        public feed(Integer a) {
            this.row_count = a;
            this.itemss = new List<items>();
        }
    }
    
    public class items{
        public String msg;
        public String interest;
        public DateTime whendt;
         
        public items( String msg, String interest, DateTime whendt) {
            this.msg = msg;
            this.interest= interest;
            this.whendt = whendt;
        }
    }
}

 

When I execute program it gives me below error;

System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set

What I'm missing?

 

Thanks!!

Hi,

 

Can we find whether the logged in user is the actual User or the Admin who can log in after providing Grant Login Access?

 

Regards,

OnDem

I'm trying to copy a new user as contact by using a trigger but I'm getting the following error

 

MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Contact, original object: User

 

trigger Acceleration_User_Copyto_Contact on User (after insert, after update) {
    
   // Map<String,User> newLead = new Map <String, User>();
    
    system.debug('Acceleration_User_Copyto_Contact Trigger....');
 
    for ( User user : System.Trigger.new)
    {
        if  (user.Email.contains('acceleration'))
        {
            system.debug('Acceleration_User_Copyto_Contact Trigger..2.');
            Integer RecordCount = [select count() from Contact c where c.Email = : user.Email];
            
            system.debug('Acceleration_User_Copyto_Contact Trigger..2a .' + RecordCount);
            
            if (RecordCount == 0)
            {
                String AccountId = '';
                for ( Account a : [Select a.Id From Account a where Name = 'Acceleration']) 
                {
                    system.debug('Acceleration_User_Copyto_Contact Trigger..3.');
                     
                    AccountId = a.Id;
                
                    Contact con = New Contact();
                    con.AccountId = AccountId ;
                    con.Email = user.Email;
                    con.Firstname = User.Firstname;
                    con.Lastname = User.Lastname ;
                    con.User__c = User.Id;
                    insert con;
                }          
            }                   
        }
        
     }
    
    
}