• Surya Kiran
  • NEWBIE
  • 80 Points
  • Member since 2013
  • Senior Software Engineer
  • UnitedHealth Group


  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 21
    Replies
Hi Everybody,
      Can anyone tell me how to run SOSL query in salesforce like soql in query editor know
Thanks in advance
I'm working on a requirement as follows: Whenever an Opportunity is created or edited, its custom region picklists (Region__c) should be overwritten with the Account region picklists (Region__c).

Trying to develop a trigger that would satisfy this requirement.

Whenever an Opportunity is created or edited, check to see if any of the custom Region__c picklists are NULL. If any are NULL, overwrite all picklist fields with corresponding data from the Account object.

Here is what I have so far:

trigger UpdateOpptyPicklists on Opportunity(Before Insert, Before Update) {
    for(Opportunity o: Trigger.new){
     Account a = [select id,Region__c,Area__c, Division__c from Account where Id=:o.AccountId];
      
        if(o.Region__c == NULL || o.Area__c == NULL || o.Division__c == NULL){
        
          o.Region__c=a.Region__c;
          o.Area__c = a.Area__c;
          o.Division__c=a.Division__c;
       }
  }
}

One major flaw with my trigger is that I have SOQL running inside a loop. How can I bulkify this trigger?

Hi Folks,

I have set a custom error message using setCustomValidity() in lightning, while clearing it is not working for lightning:input date fields. Seems it is issue from Salesforce. Please let me know if there is any workaround.

Here is the example:
Lightning Component:
<aura:component implements="force:appHostable" >
    <lightning:card footer="Card Footer" title="Hello">
        <lightning:input Label="Name" aura:id="name" value="{!v.acc.Name}" required="true"/>
        <lightning:input type="date" aura:id="date" label="Enter a date" required="true" value="{!v.acc.dhr__Custom_Date_Time__c}"/>
        <lightning:input type="date" label="Enter a date" required="true" value="{!v.acc.dhr__SLA_Expiration_Date_Time__c}"/>
        
        <lightning:button variant="brand" label="Handle Form" title="Brand action" onclick="{! c.handleForm }" />
    </lightning:card>
</aura:component>


Javascript Controller:
({
	handleForm : function(component,event,helper){
        var nameCmp = component.find("name");
        if(!$A.util.isEmpty(component.get("v.acc.Name")) && component.get("v.acc.Name")=="Salesforce"){
        	nameCmp.setCustomValidity("Name cannot be Salesforce") ;
        }else{
            nameCmp.setCustomValidity("") ;
        }
        nameCmp.reportValidity() ;
        
        var dateCmp = component.find("date");
        if(component.get("v.acc.dhr__Custom_Date_Time__c") >   component.get("v.acc.dhr__SLA_Expiration_Date_Time__c")){
        	dateCmp.setCustomValidity("Cannot be future..") ;
        }else{
            alert('clearing..');
            dateCmp.setCustomValidity("") ;
        }
        dateCmp.reportValidity() ;
    }
})


Hi,

I want to access Output field values from javascript. when I was accessing that record from visualforce page I enabled Inline edit for that field. I used document.getElementById("").InnerHTML. But I am getting entire innerHTML properties with span and div tags instead of text.

Any Ideas for this.
Hi,

We are importing .csv data from visualforce page. CSV  file contains more than 50000 records. I am taking this file from vf page and passing it to batchable class using custom iterator. If the csv file contains below 50000 (some times it might be approx 54000 but not 60000) records it's workig fine. If above 50000 I am getting the above limit exception.

Is there any way to avoid this exception ..?

Hi,

 

Currently I am working on Web services. I want to display specifc details of account record like Name, Phone, Fax, Description using APEX web services. Everthing is going cool.. but the problem is I have a custom field named as logo (data type=Rich Text Area). I want to display this field on client side when I am invoking the method..But when I am trying this it's not showing image unless I have logged in salesforce.com account. because the image url is like this

https://c.ap1.content.force.com/servlet/rtaImage?eid=0019000000NR7gE&feoid=00N90000004woLD&refid=0EM900000004YsG

 

how to display image on client side.

 

any suggestions !!!!!!!!!!!!!!!!!!!1

 

Thanks,

kiran

Hi Folks,

I have set a custom error message using setCustomValidity() in lightning, while clearing it is not working for lightning:input date fields. Seems it is issue from Salesforce. Please let me know if there is any workaround.

Here is the example:
Lightning Component:
<aura:component implements="force:appHostable" >
    <lightning:card footer="Card Footer" title="Hello">
        <lightning:input Label="Name" aura:id="name" value="{!v.acc.Name}" required="true"/>
        <lightning:input type="date" aura:id="date" label="Enter a date" required="true" value="{!v.acc.dhr__Custom_Date_Time__c}"/>
        <lightning:input type="date" label="Enter a date" required="true" value="{!v.acc.dhr__SLA_Expiration_Date_Time__c}"/>
        
        <lightning:button variant="brand" label="Handle Form" title="Brand action" onclick="{! c.handleForm }" />
    </lightning:card>
</aura:component>


Javascript Controller:
({
	handleForm : function(component,event,helper){
        var nameCmp = component.find("name");
        if(!$A.util.isEmpty(component.get("v.acc.Name")) && component.get("v.acc.Name")=="Salesforce"){
        	nameCmp.setCustomValidity("Name cannot be Salesforce") ;
        }else{
            nameCmp.setCustomValidity("") ;
        }
        nameCmp.reportValidity() ;
        
        var dateCmp = component.find("date");
        if(component.get("v.acc.dhr__Custom_Date_Time__c") >   component.get("v.acc.dhr__SLA_Expiration_Date_Time__c")){
        	dateCmp.setCustomValidity("Cannot be future..") ;
        }else{
            alert('clearing..');
            dateCmp.setCustomValidity("") ;
        }
        dateCmp.reportValidity() ;
    }
})


Hello Everyone,

While doing callout getting the error :: 
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out .

Actually i am sending request to 3rd party system based on the response iam upserting records in salesforce.
When i was doing with 1 record, it is working fine. But when i tried with bulkified manner getting the above error.

So while research i got an idea that i need to seperate the transactions for both the Callout's and DML's.
Is there any function or method that callout has been done, with that i can seperate both the transactions for DML's in salesforce and Callouts

How can i avoid this particular error??  Please suggest me !!!
hi,i wrote a class like this 

global class SoapApiAccountContact {   
    webService static List<Contact> sayContact() {
    List<contact> con=[select Id,LastName from contact where Account.Name='tvarana'];
    return con;
    }
}

for genarating wsdl file for this class i am getting this error

Apex Generation Failed
Unable to find complexType for {http://soap.sforce.com/schemas/class/SoapApiAccountContact}address

any one please help me how to create a client class to pass list of contacts to server

Hi Everybody,
      Can anyone tell me how to run SOSL query in salesforce like soql in query editor know
Thanks in advance
When to use RestRequest/RestResponse and when to use HttpResuest/HttpResponse?

I am learning REST in Saleforce. I know there are methods like GET, POST, PUT, PATCH, DELETE.
I have written a code for this (actually taken an example from a help page from Salesforce)

@RestResource(urlMapping='/FieldCases/*')
global with sharing class myRESTCaseController {
    // create  new case : POST method to create
    @HttpPost   
    global static String createNewCase(String companyName, String caseType) {
        System.debug('COMPANY: '+companyName);
        System.debug('CASE TYPE: '+caseType);
        
        List<Account> company = [Select ID, Name, Email__c, BillingState from Account where Name = :companyName];
        List<Support_Member__c> support;
        
        if(company.size() > 0) {
            support = [SELECT ID, User__c, Name, User__r.Email from Support_Member__c WHERE Support_State__c = :company[0].BillingState LIMIT 1];
        }
        List<Support_Documentation__c> doc = [SELECT ID from Support_Documentation__c WHERE Type__c = :caseType ORDER BY CreatedDate ASC LIMIT 1];
        
        if(company.size() == 0 || support.size() == 0 || doc.size() == 0) {
            return 'No support data exists for this problem';
        }
        
        Case c = new Case();
        c.OwnerId = support[0].User__c;
        c.AccountId = company[0].Id;
        c.Subject = caseType + ' for '+companyName;
        c.Status = 'Open';
        insert c;
        
        //sendEmail(companyName, company[0].Email__c, doc[0].Id, support[0].Name, support[0].User__r.Email);
        
        return 'Submitted case to '+support[0].Name+' for '+companyName+'.  Confirmation sent to '+company[0].Email__c;
    }
    
    // delete an old case : DELETE method used
    @HttpDelete
    global static String deleteOldCases() {
        String companyName = RestContext.request.params.get('companyName');
        Account company = [ Select ID, Name, Email__c, BillingState from Account where Name = :companyName];
        
        List<Case> cases = [SELECT Id, Subject, Status, OwnerId, Owner.Name from Case WHERE AccountId =: company.Id AND Status = 'Closed'];
        delete cases;
        
        return 'Closed Cases Deleted';
    }
    
    
    // update a case : PATCH method used for updation
    @HttpPatch
    global static String updateCase(String caseId, String caseStatus, String caseNote) {
        Case companyCase = [SELECT Id, Subject, Status, Description from Case WHERE Id =: caseId];
        
        companyCase.Status = caseStatus;
        companyCase.Description += '/n/n';
        companyCase.Description += caseNote;
        update companyCase;
        
        return 'Case Updated';
    }
    
    // updates a case : PUT method used to update/insert
    @HttpPut
    global static String updateCase() {
        RestRequest req;
        String companyName = req.params.get('companyName');
        Account company = [ Select ID, Name, Type, BillingState from Account where Name = :companyName];

        Attachment a = new Attachment();
        a.ParentId = company.Id;
        a.Name = 'test.png';
        a.Body = req.requestBody;
        
        insert a;
        
        return 'Attachment added';
    }
    
    // get Open case : GET method to get records
    @HttpGet
    global static List<Case> getOpenCases() {
        String companyName = RestContext.request.params.get('companyName');
        Account company = [ Select ID, Name, Email__c, BillingState from Account where Name = :companyName];
        
        List<Case> cases = [SELECT Id, Subject, Status, OwnerId, Owner.Name from Case WHERE AccountId =: company.Id];
        return cases;
        
    }
}

I want to know how to call these methods?
I suppose I can call them from cURL....if so how?
Currently I am trying to call them from Anonymous window of developer Console like this:
String companyName = 'Edge Communications';
String caseType = 'Electrical';


Http http = new Http();
//HttpRequest request = new HttpRequest(); // http format
RestRequest request = RestContext.Request; // rest format***


request.setEndpoint('https://instance.salesforce.com/services/apexrest/FieldCase?');

// calling method
request.setMethod('POST');

// pass parameteres : POST method
request.setBody('companyName='+EncodingUtil.urlEncode(companyName, 'UTF-8')+'&caseType='+EncodingUtil.urlEncode(caseType, 'UTF-8'));

// header params
request.setHeader('Authorization', 'Bearer '+userinfo.getSessionId());
request.setCompressed(true);

// response
//HttpResponse response = http.send(request);
RestResponse response = RestContext.response;***

System.debug('Request : '+request.toString());
System.debug('Response : '+response.getBody());

And I am getting error like this :
"
Response : [{"errorCode":"UNSUPPORTED_MEDIA_TYPE","message":"Content-Type header specified in HTTP request is not supported: application/x-www-form-urlencoded"}]
"

Now my concern is....when can I use RestRequest/RestResponse and when to use HttpResuest/HttpResponse?...Any help?
Hello, is it possible to expose a salesforce api over http without requiring the user to first login?  I have some salesforce data that I would like to expose to external customers through a salesforce REST api but I don't need them to create salesforce accounts to access this data by logging in first.  

Right now all of the documentation that I have found requires the end user to login to generate an authorization token, which in my case and with the data I would like to expose is not needed and an extra burden on the end user.

Maybe I am looking at this all wrong but some help or guidance would be appreciated.

Thank you.
Hi all,

We have the below requirement:

1. Create a Vf page and a button named 'Upload CSV' . The csv file contains lines/rows, each row contains 2 columns each of which is name of two custom objects.
For example, the csv file can contain below:

CustObj1Name, CustObj1Name2
TestName1, TestName2
Name1, Name2

2. On click of the button 'Upload CSV', a batch class should parse the csv and should upsert the two custom object records picking their respective name from csv. i.e. If we have CustObj1__c and CustObj2__c as custom objects, then these two custom object records shud be upserted by populating their name field from csv, say CustObj1__c.Obj1Name__c shud be populated with TestName1 and upsert CustObj1__c, similarly CustObj2__c.Obj2Name__c shud be populated with TestName2 and upsert CustObj2__c


Please let me know on the feasible solution for the above. If you have any sample code, please share which would be very helpful to me.



Thanks a lot!

Good morning,

I'm not a Developer but I was hoping someonw could give me some insight on this message that I'm receiving. It only appears when I attempt to run Exact Target Analytics in SF via the integration.   Thanks!

Operation: /apex/et4ae5__SubscriberAnalytics

By user/organization: 005d00000038Vi5/00Dd0000000gHXb

Caused the following Apex resource warnings:

Number of SOQL queries: 57 out of 100
I'm working on a requirement as follows: Whenever an Opportunity is created or edited, its custom region picklists (Region__c) should be overwritten with the Account region picklists (Region__c).

Trying to develop a trigger that would satisfy this requirement.

Whenever an Opportunity is created or edited, check to see if any of the custom Region__c picklists are NULL. If any are NULL, overwrite all picklist fields with corresponding data from the Account object.

Here is what I have so far:

trigger UpdateOpptyPicklists on Opportunity(Before Insert, Before Update) {
    for(Opportunity o: Trigger.new){
     Account a = [select id,Region__c,Area__c, Division__c from Account where Id=:o.AccountId];
      
        if(o.Region__c == NULL || o.Area__c == NULL || o.Division__c == NULL){
        
          o.Region__c=a.Region__c;
          o.Area__c = a.Area__c;
          o.Division__c=a.Division__c;
       }
  }
}

One major flaw with my trigger is that I have SOQL running inside a loop. How can I bulkify this trigger?

While doing a project I stumbled upon a problem when using inline VF page in the standard page layout, standard hovers were cuted off.
Google did not help, so I thought if there is a possibility to create a fully custom page, that uses standard page layout as a part of the page. The idea is to let users customize fileds positions an so on.
Anybody did this before? is it possible?
i have created a picklist in vf page i.e.,like locations field in that when i select a location i want to display related records regarding locations ok that's fine,

after that one when i load the page i want to display by default particular location records that is also fine but i am not getting the location name in the picklist field

it is displaying none only. how should i get that one with out selecting a location.
Hi,

I want to access Output field values from javascript. when I was accessing that record from visualforce page I enabled Inline edit for that field. I used document.getElementById("").InnerHTML. But I am getting entire innerHTML properties with span and div tags instead of text.

Any Ideas for this.
Hi Team,

Is there anyway to send the SMS without App exchange from salesforce.

Thanks and Regards,
Venkatesh
Hi All,

I'm trying to populate automatically a lookup field on a custom object, via a VF Page. So I have a small VF page, with a lookup, and a Save button with an hacked url behind the button. When I save, i'm correctly redirected to a new record on my custom object, but the lookup is populated with the ID of the previous lookup, and not the name. It is working, but it is not very user friendly !

Someone could help me on this topic ?

Thanks a lot

Here is my VF page

<apex:page standardController="Credit_Application__c">
    <apex:form >
        <apex:pageBlock title="New Credit Application" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="https://test.salesforce.com/a0d/e?who_id=&retURL=/&cancelURL=/&ent=Ev&CF00Nc0000000YaoU={!Credit_Application__c.Lessee_Name__c}&CF00Nc0000000YaoU_lkid={!Credit_Application__c.Lessee_Name__c}&00Nc0000000YKnQ=Draft&CurrencyIsoCode=CNY" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Leesee Information" columns="2">
                <apex:inputField value="{!Credit_Application__c.Lessee_Name__c}"/>
<apex:CommandButton action="https://test.salesforce.com/001/e?retURL=%2F001%2Fo&RecordType=012c0000000CrzV&ent=Account" value="Create a new Leesee Account"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Hi Guys,

I created a Button and displaying on Record Detail Page.This button opens a small VF Page.In that page i wrote some logic,when my functionality is done at that time i need to refresh the parent window as well as i need to close the child(opened) window.
I wrote like the below one, closing is working but its not refreshing parent record ID.

1st Trail :
top.parent.window.opener.location.href = "/{!rew.id}";
top.window.close();
2nd Trail :
window.opener.location.reload();
window.top.close();

Both are not working...can you justify..
We need to create Pop-up alert on Case page. We have created Visualforce page with Javascript code for calling alert and placed the Visualforce page in standard case page layout.
When we are opening case, Pop-up alert is getting displayed. However when we do any modifications to the case and save the case, Pop-up alert is again getting called. Is there any way that Pop-up gets called only when we open the case and not when we save the case?
Hi,

We are importing .csv data from visualforce page. CSV  file contains more than 50000 records. I am taking this file from vf page and passing it to batchable class using custom iterator. If the csv file contains below 50000 (some times it might be approx 54000 but not 60000) records it's workig fine. If above 50000 I am getting the above limit exception.

Is there any way to avoid this exception ..?
Error that I am getting when a scheduled batch job tries to update the contacts running the below batch class code :

Error : Feedback API _ Scheduled Job _Too many query rows: 50001

global with sharing class ContactBatch implements Database.Batchable, Schedulable, Database.AllowsCallouts { global static final Integer BATCH_SIZE = 10; public static final String RECR = 'RECR'; global List failedContacts = new List(); global List contactsToUpdate = new List(); global List admissionsOppsToUpdate = new List();

global void execute(SchedulableContext SC) {
    ContactBatch contactBatch = new ContactBatch();
    Database.executeBatch(contactBatch, BATCH_SIZE);
}

global List<Contact> start(Database.BatchableContext BC) {
    String recrValue = RECR;
    String contactId = '003V000000FZfaZ';
    String query = 'SELECT {0}, (SELECT {1} FROM Applications__r WHERE isDeleted = false ORDER BY CreatedDate DESC)' +
        ' FROM Contact WHERE FieldsHaveChanged__c = true AND isDeleted = false';// AND Id = :contactId';
System.debug(query); Set uniqueContactFields = new Set(SparkroomServices.contactFieldsToCheckFromLmsCustomSetting); uniqueContactFields.add('Current_Opp_Id__c'); uniqueContactFields.add('Inactivation_Reason__c'); uniqueContactFields.add('Service_Indicators_Non_Editable__c'); uniqueContactFields.add('Service_Indicators_Editable__c'); uniqueContactFields.add('Recruiting_Status__c'); uniqueContactFields.add('Residency_Status__c'); String contactFields = String.join(new List(uniqueContactFields), ', '); Set uniqueAdmissionOppFields = new Set(SparkroomServices.admissionOppFieldsToCheckFromLmsCustomSetting); uniqueAdmissionOppFields.add('Start_Term__c'); uniqueAdmissionOppFields.add('Sparkroom_Lead_ID__c'); String admissionOppFields = String.join(new List(uniqueAdmissionOppFields), ', '); query = String.format(query, new List{contactFields, admissionOppFields}); return Database.query(query); }

global void execute(Database.BatchableContext BC, List<Contact> contacts) {
    SparkroomServices.runBatch(contacts, failedContacts, contactsToUpdate, admissionsOppsToUpdate);
}

global void finish(Database.BatchableContext BC) {

}
}

The query is ContactBatch contactBatch = new ContactBatch(); Database.executeBatch(contactBatch, 5);

Please help.

Thanks,

Nik
While doing a project I stumbled upon a problem when using inline VF page in the standard page layout, standard hovers were cuted off.
Google did not help, so I thought if there is a possibility to create a fully custom page, that uses standard page layout as a part of the page. The idea is to let users customize fileds positions an so on.
Anybody did this before? is it possible?