• E Jayaraman Iyer
  • NEWBIE
  • 65 Points
  • Member since 2017

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 35
    Replies
hi! hope u all are doing well! i am using the <apex:tabPannel> component !  when ever the page is load the fist tab is selected by defualt  but i dont want any tab to be selected on the loading of the page . how can i do that?
Hi all! It's really general question about develop VF in SFDC platform.

Nowadays, I've worked with web designer and she is not familiar with SFDC.
In this situation, what we do together is, she write down font-end html/css/a little javascript code, and I take it and add Data integration work with SDFC.

The problem is,
I copy all code from html file she has done, and then paste to VF, of course, I need to adjust ref information with Static Resource.
But, many css occur problem like, align:center doesn't work background-color doesn't work something like that.

Is there any reason about it and easy solution?

Thanks in advance.
 

I have a requirement where I want to store data in a object regarding the amount of time spent by agent in each status.

When the agent is in online status but manually logouts out of org I couldnt get the data of time he logged out. How can I handle this?

Hi Experts, collegues

I have the following issue. we have several salesforce org's. My requirement is to read records from the lead object Org1 to a custom object in Org2. I am using the REST API and this is working fine. Credentials, API keys etc i store in custom settings.
SO basically:
- setup a connected app in ORG1
- Create some custom classes in ORG2, which call ORG 1
- Stored configuration data in custom settings.



Now you ask, what is the issue!! it is working. Well the security people do not want api, usernames etc stored in custom settings. So i found a solution on the community using an auth provider with named credentials. So the setup
- Connected app in ORG1
- Auth provider and Named credentials in ORG2
- Off course validated and authenticated.
- adjusted the custom code a bit, on the part of the endpoints.

Now it is not working anymore. I get
 -  [{"message":"This session is not valid for use with the REST API","errorCode":"INVALID_SESSION_ID"}]
- or [{"errorCode":"NOT_FOUND","message":"The requested resource does not exist"}]

So to give you some more context:

In development Console I execute:

 WebserviceHttpRest myCall = new WebserviceHttpRest();
 myCall.authenticateByUserNamePassword('key','secret','name','password', true);
 myCall.doSoqlQuery('SELECT ID,Company, Fiber__C,LG_DateOfEstablishment__c,LG_InternetCustomer__c,LG_LegalForm__c,LG_MobileCustomer__c,LG_Segment__c,LG_VisitPostalCode__c FROM lead;'); 
 
The authenticateByUserNamePassword looks like this

public void authenticateByUserNamePassword(String consumerKey, String consumerSecret, String uName, String uPassword, Boolean isSandbox) {
        // Reference documentation can be found in the REST API Guide, section: 'Understanding the Username-Password OAuth Authentication Flow' OAuth 2.0 token is obtained from endpoints:
        //  PROD orgs   : https://login.salesforce.com/services/oauth2/token
        //  SANDBOX orgs: https://test.salesforce.com/services/oauth2/token


        //Fetch inlogdata from customsettings
        IWebServiceConfig storedConfig =  WebServiceConfigLocator.getConfig('mycustomConfig') ;
        if(storedConfig == null) throw new ExMissingDataException('Invalid data set name provided');
        uName = storedConfig.getUsername();
        uPassword  = storedConfig.getPassword();

        //String uri          = 'https://' + (isSandbox ? 'test' : 'login') +  '.salesforce.com/services/oauth2/token';
        String uri          = '/services/oauth2/token';
        String clientId     = EncodingUtil.urlEncode(consumerKey,'UTF-8');   
        String clientSecret = EncodingUtil.urlEncode(consumerSecret,'UTF-8'); 
        String username     = EncodingUtil.urlEncode(uName,'UTF-8');  
        String password     = EncodingUtil.urlEncode(uPassword,'UTF-8');
 
        String body =   'grant_type=password&client_id=' + clientId + 
                        '&client_secret=' + clientSecret +
                        '&username=' + username + 
                        '&password=' + password; 
 
        HttpResponse hRes = this.send(uri,'POST',body, false);
        if (hRes.getStatusCode() != 200) 
            System.debug('[HTTP-01] OAuth 2.0 access token request error. Verify username, password, consumer key, consumer secret, isSandbox?  StatusCode=' +  hRes.getStatusCode() + ' statusMsg=' + hRes.getStatus());
            System.debug('response body =\n' + hRes.getBody());
         
 
        Map<String,String> res = (Map<String,String>) JSON.deserialize(hRes.getBody(),Map<String,String>.class);
 
        this.accessToken        = res.get('access_token');     // remember these for subsequent calls
        this.sfdcInstanceUrl    = res.get('instance_url');  
    }
 

 The send methode looks like:

     private HttpResponse send(String uri, String httpMethod, String body, Boolean contentType) {
         
        if (Limits.getCallouts() == Limits.getLimitCallouts())
            system.debug('[HTTP-00] Callout limit: ' + Limits.getCallouts() + ' reached. No more callouts permitted.');
        
        Http        h       = new Http();
        HttpRequest hRqst   = new HttpRequest();
        
        // hRqst.setEndpoint(uri );                     // caller provides, this will be a REST resource  PostMethod m = new PostMethod(url + "?_HttpMethod=PATCH");
        hRqst.setEndpoint('callout:myNamedCredential/'+ uri + '');
        system.debug('setEndpoint: callout:ZiggoOrg/' + uri);
        hRqst.setMethod(httpMethod);                // caller provides
        system.debug('setMethod: ' + httpMethod);
        hRqst.setTimeout(6000); 
        if (body != null)
            hRqst.setBody(body);                   // caller provides
               system.debug('setBody: ' + body);
        if (contentType) {
            hRqst.setHeader('Content-Type', 'application/json');
        }
        
        if (this.accessToken != null)               // REST requires using the token, once obtained for each request
            hRqst.setHeader('Authorization','Bearer ' + this.accessToken);
             system.debug('setHeader: ' + this.accessToken);
             system.debug('hRqst'+hRqst );
        return h.send(hRqst);                   // make the callout
    }  



    The setendpoint with comments is working with thew custom settings.
    

    Any ideas suggestions
I have a String which I need to convert and make it look the below in JSON.
I want to convert the String s to JSON, Please help

String allIndexes = 'Columns/Sections :1, Columns/Sections :2';

String s = 'error: "SECTION_LENGTH_EXCEEDED",' +'\n'+'message: Unable to save RuleAction record, HTML content size is bigger that expected ' +'\n'+'erroredSections : '+ allIndexes;

EXPECTED OUTPUT JSON FORMAT :
JSON : {
    error: "SECTION_LENGTH_EXCEEDED",
    message: "Unable to save sections, json object size is bigger that expected",
        erroredSections: [
          { Columns/Sections :1 }
      { Columns/Sections :2 }
        ]
    }
}


 
I have an input form in a child vf component whose fields are rendered from a field set.  
This child component is being called from a parent component where I want to validate on the parent controller whether the the required fields in child component's field set is filled or not before saving it.
So to do this I will need to access child component's data from a parent vf component's controller. But I am not sure how to access it.
Hi,

Unable to pass parameters while navigating between pages

Scenario:
Using iFrame to show the page content. 
iFrame > apex:page > apex:pageBlock 
The pageBlock contains 3 apex:components, only one out of three is rendered at a time. 
<apex:page controller="myController">
    <script>
          var localJavascriptVariable = '';
          setVariables('a', 'b', 'c');
          showComponent1();
    </script>


    <apex:pageBlock>
            <c.component1 />
            <c.component2 />
            <c.component3 />
    </apex:pageBlock>

    <apex:form >
        <apex:actionFunction name="showComponent1" action="{!renderComponent1}">
        </apex:actionFunction>
        <apex:actionFunction name="showComponent2" action="{!renderComponent2}">
        </apex:actionFunction>
        <apex:actionFunction name="showComponent3" action="{!renderComponent3}">
        </apex:actionFunction>
        <apex:actionFunction name="setVariables" action="{!assignValues}">
             <apex:param id="myValue1" assignTo="{!stringFromComponent1}" value=""/>
             <apex:param id="myValue2" assignTo="{!stringFromComponent2}" value=""/>
             <apex:param id="myValue3" assignTo="{!stringFromComponent3}" value=""/>
        </apex:actionFunction>
    </apex:form>


<apex:page>
'myController' takes care of the navigation between of the components
public class myController {

    public string stringFromComponent1 { get; set; }
    public string stringFromComponent2 { get; set; }
    public string stringFromComponent3 { get; set; }
    
    public Boolean componentVisible1 { get; set; }
    public Boolean componentVisible2 { get; set; }
    public Boolean componentVisible3 { get; set; }
    
    public myController() { 
        componentVisible1 = true;
        componentVisible2 = false;
        componentVisible3 = false;
    }

    public PageReference renderComponent1() {
        componentVisible1 = true;
        componentVisible2 = false;
        componentVisible3 = false;
        return null;
    }

    public PageReference renderComponent2() {
        componentVisible1 = false;
        componentVisible2 = true;
        componentVisible3 = false;
        return null;
    }

    public PageReference renderComponent3() {
        componentVisible1 = false;
        componentVisible2 = false;
        componentVisible3 = true;
        return null;
    }

    public PageReference assignValues() {
        stringFromComponent1 = System.currentPagereference().getParameters().get('myValue1');
        stringFromComponent2 = System.currentPagereference().getParameters().get('myValue2');
        stringFromComponent3 = System.currentPagereference().getParameters().get('myValue3');
        return null;
    }
Everytime the components are swapped, the values stored in stringFromComponent1, stringFromComponent2,  stringFromComponent3 is reset and the localJavascriptVariable looses value in it .

Question:
1. I think the component swap is rerendering the page and hence the local variables are lost, how to stop it from this behaviour?
2. While swapping another instance of  controller is created. How to let all components use same instance of same controller?

Thanks in advance!
 
1.create custom metadata type
and also created one field2.In manage drmi pilot agg, querys I make one sql query to fetch record.
fetch record from custom object3.In apex class i fetch records from custom metadata typeUser-added image4.Create a visualforce page User-added imagebut when i click preview button its not showing any recordUser-added imageplease anyone help me on this  .....thanks in advance
Hi ,

I have a functionality to develop a custom list view button by which i need to select the records and deploy them to another org.
Is there a possibility to do this for multiple records deployed in to other org.Kindly help please.

Thanks a lot in advance!!
  I want to determine the next business day if a service request is submitted on a weekend.
example: If I submit a service request on a weekend (Saturday/Sunday). The actual date received should be a Monday (which is the business day not Sunday or Saturday). Now if Monday is a holiday, I want the next business day to be the actual date.

I will store this in a different field. I will still keep track of the actual date the service was requested ( Received Date) and populate Business Day with the right date using the formula.

I don't want to use Apex if possible i want to use formulas. We already know the list of Holidays for a calendar year and it is same every other year. The only issue is when a national holiday falls on a weekend (USA) obviously the Monday becomes a holiday. I wonder how it can be handled.

If you have apex solutions too i am willing to hear you out
hi! hope u all are doing well! i am using the <apex:tabPannel> component !  when ever the page is load the fist tab is selected by defualt  but i dont want any tab to be selected on the loading of the page . how can i do that?
Hello Awesome Devs!

I have the following VF Page and Controller.  The VF Page will have a dropdown of territories, and when that dropdown has a value selected, then I woudl like to render the PageBlockSections to show the correct SOQL query on Accounts to bring back the list of records from the controller.

It seems as if any choice in the dropdown calls the Else statement in my controller and always shows those records, and does not change upon selecting a new value, it always stays as the else records.  

Can anyone help me get over the finish line here on this project to conditionally render the proper set of records on the VF page Blocks based on the selection of the drop down territory list on the VF page?

Thank you so much for any help you can provide! 

Shawn

VF Page - 
<apex:page controller="ABMController" showHeader="true" >
    <apex:form id="form">
        <h1></h1><br/>
        <apex:pageMessages />
        <apex:pageBlock mode="inlineEdit" id="Block1" >
        	<apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="SAVE"/>
            </apex:pageBlockButtons>
            
            <span id="idSpan">
            <apex:pageBlockSection title="ABM Assignment Tool" columns="1" id="Details">
           		<apex:selectList value="{!TerritoryID}" size="1">
            		<apex:actionSupport event="onchange" reRender="wrapper1,wrapper2"/>
            		<apex:selectOptions value="{!schedules}"/>
        		</apex:selectList>
            </apex:pageBlockSection>
            </span>
            
            <apex:outputPanel layout="none" id="wrapper1">
            <apex:pageBlockSection title="Assigned Accounts" collapsible="false" columns="5" rendered="{!TerritoryID != null}">
            	<apex:pageBlockTable value="{!accts}" var="a" border="1">
                    <apex:column headervalue="Account Name">
                        <apex:outputLink value="/{!a.Id}">{!a.name}</apex:outputLink>
                    </apex:column>
                    <apex:column headerValue="Owner Name">
                        <apex:inputField value="{!a.ownerId}"/>
                    </apex:column>
                    <apex:column value="{!a.Armor_Territory__c}"/>
                    <apex:column value="{!a.Status__c}"/>
                    <apex:column value="{!a.Average_TAM_Score__c}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            </apex:outputPanel>
        
        
        <apex:outputPanel layout="None" id="wrapper2">
            <apex:pageBlockSection title="Un-Assigned Accounts" collapsible="false" columns="5" rendered="{!TerritoryID != null}" >
            	<apex:pageBlockTable value="{!unassigned}" var="a" border="1">
                    <apex:column headervalue="Account Name">
                        <apex:outputLink value="/{!a.Id}">{!a.name}</apex:outputLink>
                    </apex:column>
                    <apex:column headerValue="Owner Name">
                        <apex:inputField value="{!a.ownerId}"/>
                    </apex:column>
                    <apex:column value="{!a.Armor_Territory__c}"/>
                    <apex:column value="{!a.Status__c}"/>
                    <apex:column value="{!a.Average_TAM_Score__c}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller - 
 
public class ABMController {

    public SelectOption[] getSchedules() {
        return new SelectOption[] {new SelectOption('Value1', '--Select a Territory--'),
            new SelectOption('Value2', 'Northwest'), new SelectOption('Value3', 'Southwest'), new SelectOption('Value4', 'Upper South Central')};
    }
    
    public String TerritoryID {get; set;}
    public List<Account> accts {get; set;}
    public List<Account> unassigned {get; set;}
    User sapi = [SELECT Id,Name FROM User WHERE FirstName = 'SalesStaff' LIMIT 1];
    String TerrName = TerritoryID;
    
    public ABMController(){
        
        if(TerrName == 'Value2'){
            accts = new List<Account>();
            unassigned = new List<Account>();
            accts = [SELECT ID, NAME, OwnerId, Armor_Territory__c, Status__c,Average_TAM_Score__c FROM Account WHERE Armor_Territory__c = 'Northwest' AND OwnerId !=: sapi.Id ORDER BY OwnerId ASC LIMIT 40];
            unassigned = [SELECT ID, NAME, OwnerId, Armor_Territory__c, Status__c,Average_TAM_Score__c FROM Account WHERE Armor_Territory__c = 'Northwest' AND OwnerId =: sapi.Id AND Status__c = 'Not Active' ORDER BY Average_TAM_Score__c DESC LIMIT 10];
        } else If(TerrName == 'Value3') {
            accts = new List<Account>();
            unassigned = new List<Account>();
            accts = [SELECT ID, NAME, OwnerId, Armor_Territory__c, Status__c,Average_TAM_Score__c FROM Account WHERE Armor_Territory__c = 'Southwest' AND OwnerId !=: sapi.Id ORDER BY OwnerId ASC LIMIT 40];
            unassigned = [SELECT ID, NAME, OwnerId, Armor_Territory__c, Status__c,Average_TAM_Score__c FROM Account WHERE Armor_Territory__c = 'Southwest' AND OwnerId =: sapi.Id AND Status__c = 'Not Active' ORDER BY Average_TAM_Score__c DESC LIMIT 10];
        } else {
            accts = new List<Account>();
            unassigned = new List<Account>();
            accts = [SELECT ID, NAME, OwnerId, Armor_Territory__c, Status__c,Average_TAM_Score__c FROM Account WHERE Armor_Territory__c = 'Upper South Central' AND OwnerId !=: sapi.Id ORDER BY OwnerId ASC LIMIT 40];
            unassigned = [SELECT ID, NAME, OwnerId, Armor_Territory__c, Status__c,Average_TAM_Score__c FROM Account WHERE Armor_Territory__c = 'Upper South Central' AND OwnerId =: sapi.Id AND Status__c = 'Not Active' ORDER BY Average_TAM_Score__c DESC LIMIT 10];
        }
        
        
    }
    
    
    
    public PageReference showAccounts() {
        system.debug('EXECUTED');
        return null;
    }
    
    public PageReference save(){
        update accts;
        update unassigned;
        PageReference congratsPage = Page.ABMPage;
  		congratsPage.setRedirect(true);
  		return congratsPage;
        
    }

    
}