• Suman Kundu
  • NEWBIE
  • 75 Points
  • Member since 2011
  • Technical Lead
  • PwC

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 19
    Replies
hello guys i am new to salesforce i got a doubt in controllers so please explain it.

  one custom controller,  extension A controller , and extension B controller  and  A,B,C methods for each controller when we call these controllers from VISUALFORCE which will call either custom controller or methods A B C.
Hi all, 
I need your help to read a file having name including whitespace inside a zip. Firstly I have kept the zip file in static resource, then trying to read it from apex class using page reference. I am able to access a file having no whitespace in the same directory in the zip. But when it is about space, an exception appears as below:
VisualforceException: 404 status code return from request to [URL] 
I have tried replacing the filename space with + and %20, but no luck. So need your help. 

Thanks
Suman
Hi All,
I am developing a VF page completely built in JS. After performing some action, it should redirect to newly created sobject standard page. But found issue:

Load denied by X-Frame-Options: https://na3.salesforce.com/<ID> does not permit cross-origin framing.

Though I have not used any <iframe> in my page, I am getting the above error. When I checked the firebug, I found one auto generated <iframe>, looks like:

<iframe id="contentPane" name="contentPane" onload="initContentFrame('https://c.na3.visual.force.com/apex/MyVFPage?core.apexpages.devmode.url=1', true, false , 'https://na3.salesforce.com' );" src="/blank.html" style="width: 100%; height: 100%" title="Content Pane" frameborder="0"></iframe>

I really have no clue where from it comes, and why it resists me to redirect from JS.

So it will be very helpful for me if anybody would let me know the reason and solution.

Thanks

Hi,

 

I have built a RestResource class for handling HTTPPost requests. Now everything is working properly except the response being enclosed by double quote ("). I am sending a response in xml pattern but in return type I am using type: String.

 

@HttpPost
global static String doPost(String message, String device_address)

 

I don't know what should be the response type here, and also don't know whether this return type makes the problem or not.

 

 

So I need your suggestion to resolve the issue ASAP.

 

Thanks

Suman Kundu

I am trying to build a custom dynamic lookup component. I have put this component in a form, choosing a record from object record list (from lookup) and lastly calling a method from commandButton to check record Id and name properly selected or not.

 

This is working fine when I am using it alone in a VF Page form. Getting the id and name what I am selecting in the method's system.debug(). But when I am trying this component multiple times in a PageBlockTable, it makes some problem. No issue on selecting record on each of this lookup. But when I am clicking the button to check all the lookups value in the controller's method, I found the method is not being called. In debug log, I couldn't even found the method name too.

 

I am providing my component, component controller, lookup page, component calling page and its cotroller.

 

// ==========================component ===============================================

<apex:component controller="mycompController">
    <script>
        function windowOpener(windowHeight, windowWidth, windowName, windowUri, lookupName, lookupId)
        {
            try{
                var valueNm = document.getElementById(lookupName).value;
                var valueId = document.getElementById(lookupId).value;
                var centerWidth = (window.screen.width - windowWidth) / 2;
                var centerHeight = (window.screen.height - windowHeight) / 2;
                var windowUri = windowUri + '&providedValue=' + valueNm.ReplaceAll(" ", "_").ReplaceAll("&nbsp;", "_");
                windowUri = windowUri + '&providedId=' + valueId;
                
                newWindow = window.open(windowUri, windowName, 'scrollbars=yes,width=' + windowWidth +
                    ',height=' + windowHeight +
                    ',left=' + centerWidth +
                    ',top=' + centerHeight);
            
                newWindow.focus();
                return newWindow.name;
            }catch(e){
                alert(e);
            }    
        }
        
        String.prototype.ReplaceAll = function(stringToFind, stringToReplace)
        {
            var temp = this;
            var index = temp.indexOf(stringToFind);
            while(index != -1)
            {
                temp = temp.replace(stringToFind,stringToReplace);
                index = temp.indexOf(stringToFind);
            }
            return temp;
        }
    </script>
    
    <apex:attribute name="data" description="This is the data value for the component." type="String" />
    <apex:attribute name="type" description="This is the type for the component." type="String" required="true" default=" " />
    <apex:attribute name="value" description="This is the value variable for the component." type="String" required="true" />
    <apex:attribute name="valueId" description="This is the Id value for the Lookup component." type="String" />
    <apex:attribute name="label" description="This is the label of the component." type="String" />
    <apex:attribute name="required" description="This is the name of the component." type="Boolean" />
    <apex:attribute name="fields" description="This is used for fields to be queried in Lookup" type="String"/>
    <apex:attribute name="condition" description="This is used only condition required in Lookup" type="String"/>
    
    <apex:outputPanel rendered="{!(type == 'Lookup')}">
        <apex:inputText label="{!label}" value="{!value}" required="{!required}" id="lookupName"/>
        <apex:inputHidden id="lookupId" value="{!valueId}"/>
        <a title="Search" onclick="windowOpener(350, 650, 'Search', '/apex/LookupPage?Name={!$Component.lookupName}&Id={!$Component.lookupId}&ObjectAPI={!data}&ShowFields={!fields}&Condition={!condition}', '{!$Component.lookupName}', '{!$Component.lookupId}');">
            <img class="lookupIcon" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';this.style.cursor = 'pointer';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onblur="this.className = 'lookupIcon';" alt="Search" src="/s.gif"/>                        
        </a>
    </apex:outputPanel>
    
</apex:component>

 

 

// ==========================component controller =======================================

public class mycompController
{
    public String searchText {get; set;}
    public List<SObject> searchList {get; set;}
    public Boolean showTable {get; set;}
    public String table {get; set;}
    public Map<String, String> searchNameIdMap = new Map<String, String>();
    
    public mycompController()
    {
        searchText = '';
        if(ApexPages.currentPage().getParameters().get('providedValue') != null && ApexPages.currentPage().getParameters().get('providedValue').trim() != '')
            searchText = ApexPages.currentPage().getParameters().get('providedValue').trim().replaceAll('_', ' ');
        if(ApexPages.currentPage().getParameters().get('providedId') != null && ApexPages.currentPage().getParameters().get('providedId').trim() != '')
            searchNameIdMap.put(searchText, ApexPages.currentPage().getParameters().get('providedId').trim());
    }
    
    public void search()
    {
        System.debug('========>>'+ApexPages.currentPage().getParameters().get('ObjectAPI'));
        String textName = ApexPages.currentPage().getParameters().get('Name');
        String textId = ApexPages.currentPage().getParameters().get('Id');
        String ObjectAPI = ApexPages.currentPage().getParameters().get('ObjectAPI');
        String ShowFields = ApexPages.currentPage().getParameters().get('ShowFields');
        String Condition = ApexPages.currentPage().getParameters().get('Condition');
        
        String query = '';
        table = '';
        String queryFields = '';
        if(ShowFields != null && ShowFields.trim() != '')
        {
            String tempQueryFields = '';
            System.debug('----cond> '+tempQueryFields.toLowerCase().contains('id'));
            if(!ShowFields.trim().toLowerCase().contains('id'))
            {
                tempQueryFields += 'Id, ';
            }
            if(!ShowFields.trim().toLowerCase().contains('name'))
            {
                tempQueryFields += 'Name, ';
            }
            tempQueryFields += ShowFields.trim();
            queryFields = tempQueryFields;
        }
        else
            queryFields = 'Id, Name';
        query += 'select ' + queryFields + ' from ' + ObjectAPI;
        if(Condition != null && Condition.trim() != '')
        {
            query += ' where ' + Condition;    //.replaceAll(':', '=');
        }
        
        if(searchText != null && searchText.trim() != '')
        {
            if(query.contains(' where '))
                query += ' and Name like \'%'+searchText+'%\'';
            else
                query += ' where Name like \'%'+searchText+'%\'';
            
            if(searchNameIdMap.get(searchText) != null)
                query += ' and Id = \'' + searchNameIdMap.get(searchText) + '\'';
        }
        
        query += ' order by Name limit 1000';
        System.debug('------query> '+query);
        
        Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> M=new Map<String, Schema.SObjectField>();
        M = gd.get(ObjectAPI).getDescribe().fields.getMap();
        
        List<String> tableHeaderList = new List<String>();
        List<String> tableDataList = new List<String>();
        
        for(String val : queryFields.trim().split(','))
        {
            tableHeaderList.add(val.trim().replace('__c', '').replace('_', ' '));
            tableDataList.add(val.trim());
        }
        
        table += '<table border="0" align="center" width="90%" id="lookupTable" class="tablesorter"><thead><tr>';
        for(Integer i = 0; i < tableHeaderList.size(); i ++)
        {
            if(tableHeaderList[i].trim().toLowerCase() == 'id')
                continue;
            table += '<th>'+tableHeaderList[i]+'</th>';
        }
        table+='</tr></thead><tbody>';
        
        searchList = database.query( query );
        
        for(SObject u : searchList)
        {
            table += '<tr>';
            Integer j = 0;
            String lineId = '';
            for(integer i = 0; i < tableDataList.size(); i ++)
            {    
                if(i == 0 && tableDataList[i].trim().toLowerCase() == 'id')
                {
                    lineId = String.valueOf(u.get(M.get(tableDataList[i])));
                    continue;
                }
                String val = '';
                if(i == 1)
                    val = textName+':::'+textId+':::'+(u.get(M.get(tableDataList[i])) != null ? String.valueOf(u.get(M.get(tableDataList[i]))).replaceAll(' ', ' ').replaceAll('\'', '') : 'N/A')+':::'+lineId+':'+String.valueOf(u.get(M.get(tableDataList[i]))).replaceAll(' ', '_').replaceAll('\'', '');
                if(j ++ == 0)
                {
                    table += '<td>' +
                    '<a href="#" onclick=valueSetterCloser("'+val+'")>' +
                        '<span>' + String.valueOf(u.get(M.get(tableDataList[i]))).replaceAll('\'', '') + '</span>' +
                    '</a></td>';
                }
                else
                    table += '<td>' + (u.get(M.get(tableDataList[i])) != null ? String.valueOf(u.get(M.get(tableDataList[i]))).replaceAll('\'', '') : 'N/A') + '</td>';
            }
            table+='</tr>';    
        }
        table+='</tbody></table>';
        System.debug('------table> '+table);
    }
}

 

 

//============================= calling page ==================================

<apex:page controller="ABCClass">
    
    <apex:actionStatus id="wait">
        <apex:facet name="start">Processing...</apex:facet>
    </apex:actionStatus>
    
    <apex:form >
        <apex:pageBlock id="blk">
            <apex:pageBlockTable value="{!tableContent}" var="curVal">
                <apex:column >
                    <c:mycomp data="Contact" type="Lookup" value="{!curVal.val}" valueId="{!curVal.valId}" fields="Email, Phone" required="true" label="{!curVal.label}"/>                    
                </apex:column>
            </apex:pageBlockTable>           

<!-- working fine -->
            <!--<c:mycompdata="Contact" type="Lookup" value="{!curVal.val}" valueId="{!curVal.valId}" fields="Email, Phone" required="true" label="{!curVal.label}"/>-->
                  
        </apex:pageBlock>
        
        <apex:commandButton value="Click" action="{!callM}" reRender="blk" status="wait" />
    </apex:form>
    
</apex:page>

 

//=============================calling page controller ==========================

public class ABCClass
{
    public String val {get; set;}
    public String valId {get; set;}
    public String val1 {get; set;}
    public String valId1 {get; set;}
    public Boolean chkVal {get; set;}
    public String txtVal {get; set;}
    public String txtAreaVal {get; set;}
    public String pickVal {get; set;}
    public List<MyClass> tableContent {get; set;}
    
    public class MyClass
    {
        public String val {get; set;}
        public String valId {get; set;}
        public String label {get; set;}
        
        public MyClass(String val, String valId, String label)
        {
            this.val = val;
            this.valId = valId;
            this.label = label;
        }
    }
    
    public ABCClass()
    {
        val = '';
        valId = '';
        val1 = '';
        valId1 = '';
        chkVal = true;
        txtVal = 'suman';
        txtAreaVal = '';
        pickVal = 'b';
        tableContent = new List<MyClass>();
        
        for(Integer i = 1; i <= 5; i ++)
        {
            tableContent.add(new MyClass('', '', 'My Lookup - '+i));
        }
    }
    
    public void callM()
    {
        System.debug('------->>Lookup> '+val+', '+valId);
        System.debug('------->>Lookup1> '+val1+', '+valId1);
        System.debug('------->>Checkbox> '+chkVal);
        System.debug('------->>Textbox> '+txtVal);
        System.debug('------->>Textarea> '+txtAreaVal);
        System.debug('------->>Picklist> '+pickVal);
        
        for(MyClass mc : tableContent)
        {
            System.debug('------->>'+mc.label+'> '+mc.val+', '+mc.valId);
        }
        
    }
}

 

 

//============================= lookup page ==================================

<apex:page controller="DynamicComponentController" showHeader="false" sidebar="false" action="{!search}">
    <apex:stylesheet value="{!URLFOR($Resource.TableSorter, '/TableSorter/themes/blue/style.css')}"  />
    <apex:includeScript value="{!URLFOR($Resource.TableSorter, '/TableSorter/js/jquery.js')}" />
    <apex:includeScript value="{!URLFOR($Resource.TableSorter, '/TableSorter/js/jquery.tablesorter.js')}"  />
    <style>
        #wrapper {margin: 0 auto;width:1200px; margin-left:300px; }
    </style>
    <script>
        function valueSetterCloser(details)
        {
            //alert(details);
            var arr = details.split(":::")
            lookupName = arr[0]
            lookupId = arr[1]
            dataName = arr[2]
            dataId = arr[3]
            var arr1 = dataId.split(":")
            //alert(dataName+' => '+arr1[1]+', '+arr1[1].ReplaceAll("_", " "));
            try{
                top.window.opener.document.getElementById(lookupName).value=arr1[1].ReplaceAll("_", " ");    //dataName; 
                top.window.opener.document.getElementById(lookupId).value=arr1[0];    //dataId;
                top.window.opener.document.getElementById(lookupName).focus(); 
                top.window.close();
            }
            catch(e){alert(e);}
        }
        function abc()
        {
            document.getElementById('searchResultSection').innerHTML='{!table}';
            $("#lookupTable").tablesorter({debug: true});
        } 
        window.onload=abc;
        
        String.prototype.ReplaceAll = function(stringToFind,stringToReplace)
        {
            var temp = this;
            var index = temp.indexOf(stringToFind);
            while(index != -1)
            {
                temp = temp.replace(stringToFind,stringToReplace);
                index = temp.indexOf(stringToFind);
            }
            return temp;
        }
    </script>
    <apex:sectionHeader title="Record Selector"/>
    <apex:pageBlock >
        <apex:form >
            <apex:pageBlockSection columns="1">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >Search For:&nbsp;</apex:outputLabel>
                    <apex:outputPanel >
                        <apex:inputText value="{!searchText}"/>
                        <apex:commandButton value="Go" action="{!search}"/>
                    </apex:outputPanel>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            
            <div id="searchResultSection">
            
            </div>
        </apex:form>
    </apex:pageBlock>
</apex:page>

The scenario is like we need to build a rest post method that has a functionality like calling out to Verizon. Now we have already built that and tried to call the REST api from out sider. But it is throwing a callout exception: Callout loop not allowed.

 

What it means I think we can not call a callout  from other callout.

 

Can any body suggest me what would be the alternative way or what is the option to accomplish this.

Hi,

 

I have two classes those are calling out using HTTP. These classes were working absolutely fine, but today I got an exception on just changing small thing and save that. The exception is  as follows

 

VZWCaller: line 175, column 20: Method does not exist or incorrect signature: [http].send(System.HttpRequest) at line 77 column 5

 

On 175th line, one call out is made with Http send method. I have also rollback my changes and tried Now this is impossible to believe, that http class does not have a method send containing parameter HttpRequest. So I cant understand what could be the reason to get this kind of error?

 

Please anybody help me out of this problem.

Hi,

 

I am trying to access one salesforce org's records from another one using SSO. I have already built a sF org as Identity Provider (HUB) and other as service provider(Spoke). Now it is working fine for few scenarios, like from service provider's IdP-Initiated Login URL, I can redirect to service provider without login. But I want to extract  Service Provider's records from my IdP using my apex class. For this I have followed the way it was defined in online doc, link:

http://na14.salesforce.com/help/doc/en/remoteaccess_oauth_web_sso_flow.htm

 

The class I have written in IdP is as follows:

global class OtherOrgController
{
    Webservice static String fetchFromOtherOrg()
    {
        String url = 'https://login.salesforce.com/services/oauth2/token';
        String body = '';
        body += 'grant_type=assertion';
        body += '&assertion_type=urn:oasis:names:tc:SAML:2.0:profiles:SSO:browser';
        body += '&assertion=<response code>'; //here i didn't paste actual response id
        body += '&format=urlencoded';
        HttpRequest req1 = new HttpRequest();
        req1.setEndpoint(url);
        req1.setMethod('POST');
        req1.setTimeout(60*1000);
        req1.setBody(body);
        req1.setHeader('Content-Type','application/x-www-form-urlencoded');
        Http h1 = new Http();
        String resp1 = h1.send(req1).getBody();
        return resp1;
    }
}

Here in the assertion parameter, I have used the response id got from SP's SAML Assertion Validator's result. (Is this assertion right one?). Now when ever I call this method, it gives error as follows:

error=invalid_grant&error_description=invalid%20assertion&error_uri=https%3A%2F%2Fna4.salesforce.comnull%2Fsetup%2Fsecur%2FSAMLValidationPage.apexp

Here I can't even understand why 'na4' is being involved when none of SP and IdP belong to na4.

 

Please help me out of this problem.

I have built a page where I am showing existing opportunitylineItems extracted in the controller class of this page. In this controller class I can see the discount value present (in debug log), but it doesn't show any thing for discount. Though all the other fields are showing properly.

 

In controller class:

for(OpportunityLineItem oliR : [select Id, PriceBookEntryId, PriceBookEntry.Product2Id, PriceBookEntry.Product2.Name, PriceBookEntry.Product2.ProductCode, Group_Number__c, Is_Root_Product__c, Quantity, Discount, UnitPrice, TotalPrice, ServiceDate from OpportunityLineItem where OpportunityId = :oppId order by Group_Number__c, order__c])
            {
                oppLnItemLst.add(oliR);
                System.debug('****************>>'+oliR.Discount);
            }

 

In visualforce Page:

                                    <td>
                                        {!olIL.Discount}
                                        <!--
                                        <apex:outputText value="{0, number, $###,###,##0.00}" style="float:right;">
                                            <apex:param value="{!olIL.Discount}" />
                                        </apex:outputText>
                                        -->
                                    </td>

 

I really can't find any reason for this to be happened.

Please help me.

In our application, we keep a credit card number in account object. For security purpose, intially we encrypted the card info as card number masking. It shows the card number like XXXX-XXXX-XXXX-1111. But it was making a problem when we were fetching card number from batch process, the '-' sign still remains in the data.

 

So now we have changed tha masking type to last 4 digit masking. This is not showing the card number as previous (with '-' sign) in the account view. But in the batch code, it still appears with '-' sign. which is making me problem for successful gateway transaction.

 

It would be great, if anybody kindly help me.

I have an salesforce org and an one Database.com org. Now I want to login and then fetch/update data using apex code from my salesforce org.

What we need to do in this case? Please give any idea.

I have an salesforce org and an one Database.com org. Now I want to login and then fetch/update data using apex code from my salesforce org.

What we need to this case? Please give any idea.

I have included two VF pages in a single VF page. Now both of the pages have their own controller. Now I want when a button in page1 is clicked it will call the method in controller of Page2.

 

Is there any way to do so? Please help me.

I have included two VF pages in a single VF page. Now both of the pages have their own controller. Now I want when a button in page1 is clicked it will call the method in controller of Page2.

 

Is there any way to do so? Please help me.

I want to a facebook app where from I need to login and do DQL & DML operation for Force.com. I want to use javascript to build this app in facebook.

 

Can I do this using rest api? If yes, please give a short example to login and query on Account object.

 

 

In salesforce's facebook integration, we can get data from facebook tables. But I need access salesforce database records from facebook app.

 

Is there anyway to do that? Can REST API help on this?

 

Please help me.

My requirement is something like: I have a generic trigger code, where I need to just change the object name each time and generate a new trigger from an apex code. I think trigger is also saved as a record in salesforce, so I hope it may be possible.

 

Please give me aome idea on it, if it is possible.

I am using an extension class where for some condition, an approval is processed from constructor. There is no DML operation previously used in that constructor. In the VF page, I am using a component. To avoid this error I have also used attribute allowDML="true" in the component tag. But it doesn't help at all.

 

Please help me.

public ReversePaymentController(ApexPages.StandardController con) 
    {
        this.controller = con;
        shouldRenderPageBlock = true;
        UserRole r = [select Id from UserRole where Name = 'Customer Service Managers'];
        if(r != null)
        {
            System.debug('::::::::::'+r.Id);
            o2bc__Subscription__c subs = [select Id, o2bc__Account__c, o2bc__Invoice__c, Credit_Card__c from o2bc__Subscription__c where Id = :controller.getId()];
            if(subs.o2bc__Invoice__c != null)
            {
                List<o2bc__Payment__c> pList = [select Id, Name, Mes_Transaction_ID__c , o2bc__Payment_Amount__c, o2bc__Invoice__r.Name, o2bc__Invoice_Line__c, o2bc__Invoice_Line__r.Name, o2bc__Invoice_Line__r.o2bc__Unit_Rate__c, o2bc__Invoice_Line__r.o2bc__Subscription__c, o2bc__Account__c, o2bc__Account__r.Name, o2bc__Invoice__c, o2bc__Payment_Method__c, o2bc__Has_Processed__c, o2bc__Refund_Amount__c, o2bc__Status__c from o2bc__Payment__c where o2bc__Invoice__c = :subs.o2bc__Invoice__c and o2bc__Payment_Method__c = 'Credit Card'];
                if(pList != null && pList.size() > 0)
                {
                    for(o2bc__Payment__c pay1 : pList)
                    {
                        if(String.valueOf(pay1.o2bc__Status__c).equals('Processed') && pay1.o2bc__Has_Processed__c)
                        {
                            pay = pay1;
                            break;
                        }    
                    }
                    if(pay != null)
                    {
                        payamt = pay.o2bc__Payment_Amount__c;
                        payMethod = pay.o2bc__Payment_Method__c;
                        hasProcessed = pay.o2bc__Has_Processed__c; 
                        refAmount = String.valueOf(payamt);   
                        note = '';
                        reason = '';    
                        if(UserInfo.getUserRoleId() != r.Id)
                        {
                            // create approval
                            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
                            req.setComments('Submitted for reversing payment.');
                            req.setObjectId(pay.Id);
                            Approval.ProcessResult result = Approval.process(req); //throwing error line:52
                            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'CSR Manager is only granted to do this process.'));
                            shouldRenderPageBlock = false;
                        }
                    }
                    else
                    {
                        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'Reverse Payment is only allowed on processed payments.'));
                        shouldRenderPageBlock = false;
                    }
                }
                else
                {         
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'There is no payment processed by Credit Card.'));
                    shouldRenderPageBlock = false;
                } 
            }
            else
            {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'There is no invoice in this subscription.'));
                shouldRenderPageBlock = false;
            }  
        }
        else
        {
            
        }
    } 
Here from 52nd line where process method has been called, throws this error.
I have used a component where I have also used allowDML="true", but still it throws error.
Please help me.

In a test class, I have written three test methods like

 

@isTest

public class TestClass

{

static testMethod void testMethod1()

{

Test.startTest();

System.debug('Current User Id: '+UserInfo.getUserId());

.....

.....

Test.stopTest();

}

static testMethod void testMethod2()

{

Test.startTest();

System.debug('Current User Id: '+UserInfo.getUserId());

.....

.....

Test.stopTest();

}

static testMethod void testMethod3()

{

Test.startTest();

System.debug('Current User Id: '+UserInfo.getUserId());

.....

.....

Test.stopTest();

}

static testMethod void testMethod4()

{

Test.startTest();

System.debug('Current User Id: '+UserInfo.getUserId());

.....

.....

Test.stopTest();

}

}

In this kind of scenario, a null pointer exception is coming from testMethod3, but in all the other methods it is not giving any error. I can't understand what is the reason of showing this error.

Please help me.

I have an VF page on Account and after completing process, it redirects to another page which should open the newly created child object in subtab and current page should redirect to parent object.

 

here is the code for opening subtab from 2nd page:

 

<apex:page standardController="Account" extensions="SubscriptionExtController">
    <apex:includeScript value="/support/console/22.0/integration.js"/>
    <script type="text/javascript">
        var primaryTabId = '{!accID}';
        function testOpenSubtab() {
        
            //First find the ID of the primary tab to put the new subtab in
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
        }
        
        var openSubtab = function openSubtab(result) {
         
            //Now that weve got the primary tab ID, we can open a new subtab in it
            sforce.console.openSubtab(primaryTabId, '{!$Site.Prefix}/{!retId}', true, 'New Payment', null, openSuccess, 'newcaseSubtab');
        };
        
        var openSuccess = function openSuccess(result) {
         
            //Report whether we succeeded in opening the subtab
            if (result.success == true) {
               alert('subtab successfully opened..');
            } else {
               alert('subtab cannot be opened..');
            }
        };
        testOpenSubtab();
        
    </script>
</apex:page>

 

Here both 1st and 2nd page are using same class as extension and retId, accId are populated from 1st page[both are assigned properly].

 

The problem is that it is alerting "subtab cannot be opened.."

What should be done?

Trying to complete this superbadge challenge with a fresh TP, trying to check in challenge 1 and got the below error. 
Tried with an other freshly created TP still got the same error but different error code, please help, thanks
User-added image
The call for service field description in the requirement is way different than what trailhead is actually validating.

User-added image
I am seeing the following error when attempting to check the first challenge in the Process Automation Specialist Superbadge:

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: SJNXHSJT

I am using a brand new DE org. Has anyone seen something similar for this superbadge?
hello guys i am new to salesforce i got a doubt in controllers so please explain it.

  one custom controller,  extension A controller , and extension B controller  and  A,B,C methods for each controller when we call these controllers from VISUALFORCE which will call either custom controller or methods A B C.

I have a page which queries to data from a customer table. This is then displayed in a pageblocktable in a pageblock with many row.

 

I want to have (if possible) a pageblock that will display the details of a record based on a record being selected 'onclick' but I can't seem to figure out how to rerender the pageblock based on clicking an item in the pageblocktable. I have tried using the actionSupport but this doesn't see to work inside the pageblocktable?

 

Any help is appreciated.

Hi,

 

I want to show Salesforce related content in custom vf page of opportunity as related list. so I require relationship name for this object. when I see opportunity pagelayout this available as Related content.

 

Can anybody help.

 

Thanks,

Himanshu

I have included two VF pages in a single VF page. Now both of the pages have their own controller. Now I want when a button in page1 is clicked it will call the method in controller of Page2.

 

Is there any way to do so? Please help me.

public ReversePaymentController(ApexPages.StandardController con) 
    {
        this.controller = con;
        shouldRenderPageBlock = true;
        UserRole r = [select Id from UserRole where Name = 'Customer Service Managers'];
        if(r != null)
        {
            System.debug('::::::::::'+r.Id);
            o2bc__Subscription__c subs = [select Id, o2bc__Account__c, o2bc__Invoice__c, Credit_Card__c from o2bc__Subscription__c where Id = :controller.getId()];
            if(subs.o2bc__Invoice__c != null)
            {
                List<o2bc__Payment__c> pList = [select Id, Name, Mes_Transaction_ID__c , o2bc__Payment_Amount__c, o2bc__Invoice__r.Name, o2bc__Invoice_Line__c, o2bc__Invoice_Line__r.Name, o2bc__Invoice_Line__r.o2bc__Unit_Rate__c, o2bc__Invoice_Line__r.o2bc__Subscription__c, o2bc__Account__c, o2bc__Account__r.Name, o2bc__Invoice__c, o2bc__Payment_Method__c, o2bc__Has_Processed__c, o2bc__Refund_Amount__c, o2bc__Status__c from o2bc__Payment__c where o2bc__Invoice__c = :subs.o2bc__Invoice__c and o2bc__Payment_Method__c = 'Credit Card'];
                if(pList != null && pList.size() > 0)
                {
                    for(o2bc__Payment__c pay1 : pList)
                    {
                        if(String.valueOf(pay1.o2bc__Status__c).equals('Processed') && pay1.o2bc__Has_Processed__c)
                        {
                            pay = pay1;
                            break;
                        }    
                    }
                    if(pay != null)
                    {
                        payamt = pay.o2bc__Payment_Amount__c;
                        payMethod = pay.o2bc__Payment_Method__c;
                        hasProcessed = pay.o2bc__Has_Processed__c; 
                        refAmount = String.valueOf(payamt);   
                        note = '';
                        reason = '';    
                        if(UserInfo.getUserRoleId() != r.Id)
                        {
                            // create approval
                            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
                            req.setComments('Submitted for reversing payment.');
                            req.setObjectId(pay.Id);
                            Approval.ProcessResult result = Approval.process(req); //throwing error line:52
                            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'CSR Manager is only granted to do this process.'));
                            shouldRenderPageBlock = false;
                        }
                    }
                    else
                    {
                        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'Reverse Payment is only allowed on processed payments.'));
                        shouldRenderPageBlock = false;
                    }
                }
                else
                {         
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'There is no payment processed by Credit Card.'));
                    shouldRenderPageBlock = false;
                } 
            }
            else
            {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'There is no invoice in this subscription.'));
                shouldRenderPageBlock = false;
            }  
        }
        else
        {
            
        }
    } 
Here from 52nd line where process method has been called, throws this error.
I have used a component where I have also used allowDML="true", but still it throws error.
Please help me.

In a test class, I have written three test methods like

 

@isTest

public class TestClass

{

static testMethod void testMethod1()

{

Test.startTest();

System.debug('Current User Id: '+UserInfo.getUserId());

.....

.....

Test.stopTest();

}

static testMethod void testMethod2()

{

Test.startTest();

System.debug('Current User Id: '+UserInfo.getUserId());

.....

.....

Test.stopTest();

}

static testMethod void testMethod3()

{

Test.startTest();

System.debug('Current User Id: '+UserInfo.getUserId());

.....

.....

Test.stopTest();

}

static testMethod void testMethod4()

{

Test.startTest();

System.debug('Current User Id: '+UserInfo.getUserId());

.....

.....

Test.stopTest();

}

}

In this kind of scenario, a null pointer exception is coming from testMethod3, but in all the other methods it is not giving any error. I can't understand what is the reason of showing this error.

Please help me.

I have created a VFPage where I have code a line like:

<apex:inputHidden id="chosenItemId" value="{!cItemId}"/>

 

Here cItemId which is a variable of Id type, is defined in controller like

public Id cItemId{get; set;}

 

In the controller's contructor, I haven't assigned any value to it.

Now in page, whenever ajax is called, salesforce tries to assign(set) its value with blank character. And this makes all the problem because it tries to validate Id pattern with blank character.

 

So what I do in this scenario?

Hi all,

  I have some problem in treeview. script and java query is not working .plz correct the code.

 

 

 

 

plugin Download : http://bassistance.de/jquery-plugins/jquery-plugin-treeview/

 

Reference Code :http://www.forcetree.com/2011/04/tree-view-in-visualforce-page.html

 

plugin used :Jquerytreeview

 

 

VF page:

 

<apex:page sidebar="false" controller="treenodes" showheader="false">
<!-- Include the Jquery Script files -->
<link rel="stylesheet" href="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/jquery.treeview.css')}"/>
<script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/lib/jquery.js')}" type="text/javascript"></script>
<script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/lib/jquery.cookie.js')}" type="text/javascript"></script>
<script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/jquery.treeview.js')}" type="text/javascript"></script>
<!-- End of Javascript files -->
<script type="text/javascript">
$(function() {
$("#tree").treeview({
collapsed: false,
animated: "medium",
control:"#sidetreecontrol",
persist: "location"
});
})
</script>
<br/> <br/> <br/>
<!-- Tree -->
<div class="treeheader" style="height:0px;">&nbsp;</div>
<div id="sidetreecontrol"><a href="?#"><font style="color:blue;">Collapse All</font></a> | <a href="?#"><font style="color:blue;">Expand All</font></a></div>
<ul id="tree">
<apex:repeat value="{!mainnodes}" var="parent">
<li><strong><apex:outputtext style="color:blue;" escape="false" value="{!parent.gparent.Name}"/></strong>
<ul>
<apex:repeat value="{!parent.parent}" var="child">
<li><span class="formattextcon"><apex:outputtext style="color:green;" escape="false" value="{!child.LastName}"/></span>
<ul>
<apex:repeat value="{!child.Cases}" var="gchildren">
<li> <span class="formattextcon"> <apex:outputtext escape="false" style="color:red;" value="{!gchildren.CaseNumber}"/> <b>||</b> &nbsp;<apex:outputtext escape="false" value="{!gchildren.Subject}"/> </span> </li>
</apex:repeat>
</ul>
</li>
</apex:repeat>
</ul>
</li>
</apex:repeat>
</ul>
<!-- End of Tree -->
</apex:page>

 

 

class:

 

public class treenodes {

/* Wrapper class to contain the nodes and their children */
public class cNodes
{

public List<Contact> parent {get; set;}
Public Account gparent {get;set;}

public cNodes(Account gp, List<Contact> p)
{
parent = p;
gparent = gp;
}
}
/* end of Wrapper class */

Public List<cNodes> hierarchy;

Public List<cNodes> getmainnodes()
{
hierarchy = new List<cNodes>();
List<Account> tempparent = [Select Id,Name from Account];
for (Integer i =0; i< tempparent.size() ; i++)
{
List<Contact> tempchildren = [Select Id,FirstName,LastName,(Select Id,CaseNumber,Subject from Cases) from Contact where AccountId = :tempparent[i].Id];
hierarchy.add(new cNodes(tempparent[i],tempchildren));
}
return hierarchy;
}
}

 

please help me

I am working on a visualforce page where there is a extension controller. Now in this controller, I am overriding the save method which returns PageReference. Here when I am returning Page.AccountTabbed, it makes the url as follows:

https://c.cs3.visual.force.com/apex/AccountTabbed?id=001Q000000Q2rMJ&sfdc.override=1

 

But I need the url like:

https://c.cs3.visual.force.com/apex/AccountTabbed?id=001Q000000Q2rMJ&sfdc.override=1&openTab=NewSubscription

[Need to add 'openTab=NewSubscription' at the end]

 

I have tried it like

                PageReference pageAcc = Page.AccountTabbed;
                pageAcc.getParameters().put('openTab', 'NewSubscription');
                return pageAcc;

But it doesn't change the url.

 

Can anybody help me out...