• Ronak Patel
  • NEWBIE
  • 50 Points
  • Member since 2012

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 20
    Replies

I'm trying to retrieve the selected picklist item from the Case object, field Status. My objective is to use this value for a condition and eventually set a new one based on a different logic. But my main issue is every time I try to query the selected item for the Case object I encounter this issue:

 

"System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Case.Status"

 

You may see my sample code below: This is just part of my debugging to atleast display the selected value on the error message, but I could not even get the selected item

 

for (Case c:cases){
            Case parentCase;
            String parentId = c.ParentId;
            String siblings = ' :: ';
            String selectedStat;
            String display='';
            
            List<Case> siblingCases = new List<Case>{};
            parentCase = [select Subject, Id from Case where Case.Id = :parentId];
           
            display = parentCase.Status;
            c.addError(display);

}

  • January 18, 2012
  • Like
  • 0
I have developed a custom VF page for manipulating Opportunity Product sObject in addition to default page, which is also being used. I want to be able to fire after update trigger only if update to the record is originating from default page. I have created a custom field on the object that keeps track of the originating page but I'm not sure how to enforce setting field value when the update is originating from default page. Perhaps there is a better way for controlling the logic? Thanks
  • January 16, 2012
  • Like
  • 0

How  we can override  the message provided by the required validation in Page Layout for Required field?

Hello,

 

Can anybody tell me that 

 

How i can use list variable value from controller in javascript without using apex:repeat in visualforce page.

 

 

I have one list<String> in controller with 1000 records.

i want that recoerds in javascript so i can't use apex:repeat because of (page view size limit)

 

Reply fast...

I have one Public Function which Calculate Distance between two location

Public Integer getdistace(location1,location2).

Now i have to make one query which can ues this function in soql query to get all records which have min distance 50 km.

how to use this function in soql query?

 

Help..

Can Anybody tell me how i can override standard button of every object with same Visualforce page?

i want same vf page for every object edit layout..

 

help..

Is there any way to get the List of Visual Force pages in My Org pragmatically?

public boolean validateEmail()

{
if(!isEmpty(email))
{
String regExp = '/^((([a-z]|\\d|[!#\\$%&\\'\\\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&\\'\\\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))$/i';
Pattern perObject=Pattern.compile(regExp);
Matcher MyMatcher = perObject.matcher(email);
if(MyMatcher.matches())
{
return true;
}
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Email'));
return false;
}
return true;
}

How to learn Apex language in a proper way.

Hi,

 

 

Here is my part of code..

 

 

 schema.describefieldresult dfield;

Map <String, Schema.SObjectField> fieldMap = Schema.SObjectType.Opportunity.fields.getMap();
for(Schema.SObjectField sfield : fieldMap.Values()){
dfield = sfield.getDescribe();
Pair field = new Pair();
field.key = dfield.getname();
field.label = dfield.getLabel();
field.fieldname = dfield.getname();
field.val = dfield.getDefaultValueFormula();
fields.add(field.label);

if(field.fieldname== 'npe01__Contact_Id_for_Role__c'){
field.val =contactId;
opt.put(field.fieldname,field.val);
}
}

 

 

But, I got too many field describes..

 

Can any one help me out..

 

Thanks

Anu

I'm trying to retrieve the selected picklist item from the Case object, field Status. My objective is to use this value for a condition and eventually set a new one based on a different logic. But my main issue is every time I try to query the selected item for the Case object I encounter this issue:

 

"System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Case.Status"

 

You may see my sample code below: This is just part of my debugging to atleast display the selected value on the error message, but I could not even get the selected item

 

for (Case c:cases){
            Case parentCase;
            String parentId = c.ParentId;
            String siblings = ' :: ';
            String selectedStat;
            String display='';
            
            List<Case> siblingCases = new List<Case>{};
            parentCase = [select Subject, Id from Case where Case.Id = :parentId];
           
            display = parentCase.Status;
            c.addError(display);

}

  • January 18, 2012
  • Like
  • 0

hi ,

 i m creating a daynamic query .its thorughing error

System.QueryException: unexpected token: '.'

 

Query is like this

 

soql = 'p.Name, p.Location__c From Property__c p where Name != null';
        
                string[] locations = t.Location_Tenant__c.split(';',0);
                list<String> loc= new list<String>();
                for(string l :locations){
                    loc.add( '\''+l+'\'');
                }            
                   if (loc != null && loc.size() > 0){                                   
                    soql += ' and Location__c in '+loc ;                
                   }       
             
                pList = Database.query(soql );

  system.debug('--soql---'+soql);

|DEBUG|--soql---Select p.Name, p.Location__c, p.Id From Property__c p where Location__c in ('Art Museum', 'Avenue of the Arts', 'Bella Vista', 'Brewerytown', 'Chestnut Hill', 'Chinatown', 'East Falls', 'East Oak Lane', 'Fairmount', 'Fishtown', ...)


here i m quering for location.its working fine till the last vlaue in location(Fishtown). but after adding one more location it gives me above error.

 

I m asuming that the dot in the query is giving me error, but should not give.

 

How can i resolve this error..?

 

 

Thanks

Shailu

 


  • January 17, 2012
  • Like
  • 0
I have developed a custom VF page for manipulating Opportunity Product sObject in addition to default page, which is also being used. I want to be able to fire after update trigger only if update to the record is originating from default page. I have created a custom field on the object that keeps track of the originating page but I'm not sure how to enforce setting field value when the update is originating from default page. Perhaps there is a better way for controlling the logic? Thanks
  • January 16, 2012
  • Like
  • 0

Hi All,

Need urgent help in writing a test class for the below controller  , not sure how i can do it .

Help really appreciated

 

Regards

Tom

 

 

public without sharing class RelatedListController{

    private list<sObject> mSObjects;
    public list<sObject> SObjects{
        get{return mSObjects;}
        set{
            numObjects = value==null||value.isEmpty() ? 0 : value.size();
            DescribeSObjectResult res = value.getsObjectType().getDescribe();
            isDeletable = res.isDeletable();
            isCreateable = res.isCreateable();
            isUpdateable = res.isUpdateable();
            defaultTitle = res.getLabelPlural();
            isActivity = res.getSObjectType()==Task.SObjectType||res.getSObjectType()==Event.SObjectType;
            map<String,Schema.SObjectField> fieldMap = res.fields.getMap();
            DescribeFieldResult fieldRes = isActivity ? fieldMap.get('Subject').getDescribe() : fieldMap.get('Name').getDescribe();
            nameLabel = fieldRes.getLabel();
            nameField = fieldRes.getName();
            keyPrefix = res.getKeyPrefix();
            mSObjects = value;
        }
    }
        
    private String defaultTitle;
    private String overrideTitle;
    
    public String parameters {
        get{return parameters==null ? '' : parameters;}
        set;}
    
    public String PageTitle{
        get{return overrideTitle==null||overrideTitle=='' ? defaultTitle : overrideTitle;}
        set{overrideTitle = value;}}
    
    public String buttonLabel{
        get{return overrideButton==null||overrideButton=='' ? String.format(System.Label.New_Button,new list<String>{PageTitle}) : overrideButton;}
        set{overrideButton = value;}}
    
    private String overrideButton;
    
    private integer numObjects;
    public integer rowIncrement{
        get{return numObjects-mRows<mRows ? numObjects-mRows : mRows;}}
    
    private integer mRows;
    public integer rows{
        get{
            if(mRows==null||mRows==0){
                mRows = numObjects<5 ? numObjects : 5;
            }
            return mRows;
        }
    }
    
    public String retURL{
        get{return retURL==null ? '' : 'retURL=' + retURL;}
        set;}
    
    public boolean noRecords{
        get{return numObjects==0;}}
    
    public boolean moreRows{
        get{return mRows<numObjects;}}
    
    public String keyPrefix {get;private set;}
    public String nameLabel {get;private set;}
    public String nameField {get;private set;}
    public boolean isActivity{get;private set;}
    public boolean isUpdateable{get;private set;}
    public boolean isDeletable{get;private set;}
    public boolean isCreateable{get;private set;}
    public ApexPages.PageReference newRecord(){
        return new ApexPages.PageReference('/' + keyprefix + '/e' + parameters);}
    
    public ApexPages.PageReference incrementRows(){
        mRows = mRows + rowIncrement;
        return null;}
}

I'm looking for some help, either code samples or documentation to point me towards that can help me achieve this. On an existing VF page, we are currently dislpaying Proposal__c record data and we are exposing and collecting data already.

 

What I need now is to be able to select a Contact, whose Account is associated to that record - in a picklist form or list form (most of our accounts for this purpose are <50 contacts).

 

On each Proposal__c is a Vendor__c (Contacts lookup). So basically, i need some help constructing the SOQL query to return the list of other Vendors (Contact lookup) associated to that Account. The user will basically be able to save to the record, one other contact. I'm not sure if a picklist or lookup is going to be easier in this scenario. 

 

Relevant code below:

<apex:page standardController="Proposal__c" extensions="ProposalExtension" tabStyle="Proposal__c" cache="false">
    <apex:pageMessages id="pageErrors"></apex:pageMessages>
    <apex:sectionHeader title="New Award"/>
    <apex:form id="awardForm">
        <apex:pageBlock title="Bid Detail" id="awardBlock" mode="edit">          
            <apex:pageBlockButtons >
                <apex:commandButton value="Send LOE" action="{!sendLOE}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Bid Information" columns="2" collapsible="false" showHeader="false">
                <apex:outputField value="{!bid.Vendor__r.Name}"/>        <apex:outputField value="{!bid.Bid_Date__c}"/>  
                <apex:outputField value="{!bid.Bid_Amount__c}"/>         <apex:outputField value="{!bid.Bid_Deliver_By__c}"/>  
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Award Information" id="results" columns="2" collapsible="false">     
                <apex:inputField value="{!bid.Award_Amount__c}" required="true"/>        <apex:inputField value="{!bid.Awarded_Date__c}" required="true"/> 
                <apex:inputField value="{!bid.Award_Deliver_By__c}" required="true"/>    <apex:inputField value="{!bid.Award_Comments__c}"/> 
            </apex:pageBlockSection>          
        </apex:pageBlock>      
    </apex:form>
</apex:page>

 

 

  • January 13, 2012
  • Like
  • 0

trigger HandleProductionPriceChange on<a href="http://www.buywatchesandjewelry.com/"> rolex </a> Marchandise__c (after update) {
List<Line_Item__c> openLineItems=[SELECT j.Unit_Price__c,j.Merchandise__r.Price__c FROM Line_Item__c j
 WHERE j.Invoice_Statement__r.Status__c='Negotiating' AND j.Merchandise__r.id IN :Trigger.new FOR UPDATE];

for(Line_Item__c Ii:openLineItems){
if(Ii.Merchandise__r.Price__c < Ii.Unit_Price__c){
    Ii.Unit_Price__c=Ii.Merchandise__r.Price__c;
    }
 }
 update openLineItems;
}

 

 

 

Error: Compile Error: Didn't understand relationship 'Merchandise__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 2 column 34

 

 

 

Unable to figure out the problem.

I had written this trigger on force IDE and while saving it gave an error :File only saved locally,not to server

Hello,

 

Can anybody tell me that 

 

How i can use list variable value from controller in javascript without using apex:repeat in visualforce page.

 

 

I have one list<String> in controller with 1000 records.

i want that recoerds in javascript so i can't use apex:repeat because of (page view size limit)

 

Reply fast...

Hi All,

    I am writing code like this.for displaying pointer in the google maps in vf page based on the address of the account object.

<apex:page standardController="Account" sidebar="false" showHeader="false">

<head>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
var map;
var geocoder;
var address;

function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(40.730885,-73.997383), 15);
map.addControl(new GLargeMapControl);
GEvent.addListener(map, "click", getAddress);
geocoder = new GClientGeocoder();
}

function getAddress(overlay, latlng) {
if (latlng != null) {
address = latlng;
geocoder.getLocations(latlng, showAddress);
}
}

function showAddress(response) {
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Status Code:" + response.Status.code);
} else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(
'<b>orig latlng:</b>' + response.name + '<br/>' +
'<b>latlng:</b>' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '<br>' +
'<b>Status Code:</b>' + response.Status.code + '<br>' +
'<b>Status Request:</b>' + response.Status.request + '<br>' +
'<b>Address:</b>' + place.address + '<br>' +
'<b>Accuracy:</b>' + place.AddressDetails.Accuracy + '<br>' +
'<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
}
}

$(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.Billingstate}, " + "{!Account.BillingPostalCode}, " + "{!Account.BillingCountry}";

var infowindow = new google.maps.InfoWindow({
content: "<b>{!Account.Name}</b><br>{!Account.BillingStreet}<br>{!Account.BillingCity}, {!Account.Billingstate}, {!Account.BillingPostalCode}<br>{!Account.BillingCountry}"
});

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[0].geometry.location,
map: map,
title: "{!Account.Name}",
draggable:true


});

//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 onload="initialize()">
<div id="map"></div>
</body>
</apex:page>

 

 

But i want extension like when dragging the pointer from oone location (ameerpet) to another location like(madhura nager) then automatically update the address in the account object as madhuranagar instead of ameerpet>Any one can u help me this.Its urgent for me.

 

Thanks in advance.

anu

I have one Public Function which Calculate Distance between two location

Public Integer getdistace(location1,location2).

Now i have to make one query which can ues this function in soql query to get all records which have min distance 50 km.

how to use this function in soql query?

 

Help..

i need to send a Billions of emails to contact using Batch Apex .i am New in Salesforce Apex . how can do this Batch Apex for MassEmail to Contact. please help me .......................

  • January 06, 2012
  • Like
  • 0

Can Anybody tell me how i can override standard button of every object with same Visualforce page?

i want same vf page for every object edit layout..

 

help..

Hi ,

 

By mistake I wrote code for devbox which not going to work at the time of deployment

 

Please let me know how to change this code , so It can work out in QA and production

 

url='/500/e?cas5=Incident&ent=Case&nooverride=1&&retURL=%2F500%2Fo&RecordType='+results[0].Id+'&CF00NW0000000Fgdg='+result12[0].Name+'&cas4='+result13[0].Name+'&00NW0000000FsWb='+results[0].name;

I'm in the process of packaging some code that includes callouts to Google Maps for geocoding. The code works just fine in my development org, but since the package could be installed on any Salesforce instance, I can't always use a Google Maps API key that's based on my development org's instance. Fortunately, in Google Map in Visualforce Page, I found that I can use a key based on this URL:  http://force.com

 

This seems to work, except now I get G_GEO_TOO_MANY_QUERIES.

 

Is Google's "too many queries" limit based on all requests coming from http://force.com? That would make sense from Google's perspective, but from the perspective of a single org on a single Salesforce instance, it doesn't seem fair that every other instance's org's requests should count against my limit?

 

Is there any way to create a Google Maps API key that's specific to my own org (or an org my package is installed in), so that only requests made from my org count against my limit.

 

For reference, see my post from late 2008: http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=10535

 

Thanks--

  • May 01, 2009
  • Like
  • 0