1

I have a custom visualforce page and controller extension that is working. There is one getter that I do not understand why it works. I was hoping someone could explain it to me. In the below code I do Public String merchantNumber{get;set;} and never give it a value. It is just an empty getter. And in my javascript I say sforce.console.openPrimaryTab(undefined, '/' + id, true, '{!merchantNumber}', 'Case On Tab');

The correct merchantNumber populates in the tabLabel when the page pops. How is this possible? Where is it getting the value from? It perplexes me because it is a variable I made up, it's not a custom field or object, and I don't define it. Any insight would be great!

VFP:

<apex:page id="casesOnCase" standardController="Case" extensions="casesOnCaseController">
<apex:includeScript value="/support/console/26.0/integration.js"/>

<script type="text/javascript">

function openPrimaryTabCase(){
   var href = event.currentTarget.href;
   console.log(href); 
   var arrayItem = href.split('.com/');
   var endIndexOfSubstring = arrayItem[1].indexOf('/');
   var id;
   if (endIndexOfSubstring === -1) {
        id = arrayItem[1];
        console.log('this is href2: ' + id);
   }
   else {
       id = arrayItem[1].substring(0, endIndexOfSubstring);
       console.log('this is href: ' + id);
       sforce.console.openPrimaryTab(undefined, '/' + id, true, **'{!merchantNumber}'**, 'Case On Tab');
   }
}


</script>

<apex:pageBlock >
    <apex:pageBlockTable value="{!caseOnCase}" var="item">
        <apex:column headerValue="Merchant Number"><apex:outputLink value="{!URLFOR($Action.Case.View, item.Id)}" onclick="openPrimaryTabCase(); return false;">{!item.Merchant_Number__c}</apex:outputLink></apex:column>
        <apex:column headerValue="Created Date" value="{!item.CreatedDate}"/>
        <apex:column headerValue="Returned Payment Type" value="{!item.Returned_Payment_Type__c}"/>
        <apex:column headerValue="Collections Status" value="{!item.Collections_Status__c}"/>
        <apex:column headerValue="Status" value="{!item.Status}"/>
        <apex:column headerValue="Owner Name" value="{!item.Owner.Name}"/>
        <apex:column headerValue="Opportunity Name" value="{!item.Opportunity__r.Name}"/>-->
    </apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

Controller:

public with sharing class casesOnCaseController {
   public List<Case> caseOnCase {get;set;}
   public Id strAccountId;
   public String currentPageId {get;set;}
   public String bananass {get;}
   **Public String merchantNumber{get;set;}**

public casesOnCaseController(ApexPages.StandardController controller) {
    system.debug('this is the bananass: ' + bananass);
    currentPageId = controller.getRecord().id;
    system.debug('this is the currentpageid: ' + currentPageId);

    if (currentPageId != NULL) {
        List<Case> merchNumber = [SELECT AccountId FROM Case WHERE Id = :currentPageId LIMIT 1];
        for (Case c : merchNumber) {
            strAccountId = c.AccountId;
            system.debug('this is the bananass in for loop: ' + bananass);
        }
        caseOnCase = [SELECT Merchant_Number__c, CreatedDate, Returned_Payment_Type__c, Collections_Status__c, Status, Owner.Name, Opportunity__r.Name, CaseNumber FROM Case Where AccountId = :strAccountId AND Id != :currentPageId ORDER BY CreatedDate DESC ];
        system.debug('this is all of the cases: ' + caseOnCase);
    }
}
}

UPDATE:

See photo: When I click the Merchant Number, it pops the tab with the correct Case Number

I should also mention, when I take out the merchantNumber getter, the page breaks as expected. When I add a value to merchantNumber, it is not dynamic and retains one value for all merchant numbers

UPDATE 2: Merchant Number is Null

Merchant Number is NULL

0

1 Answer 1

2

I do not think the getter/setter is actually doing anything for you.

This is the methods definition:

sforce.console.openPrimaryTab(id:String, url:URL, active:Boolean, (optional)tabLabel:String, (optional)callback:Function, (optional)name)

What you are calling:

sforce.console.openPrimaryTab(undefined, '/' + id, true, '{!merchantNumber}', 'Case On Tab');

Which becomes:

sforce.console.openPrimaryTab(undefined, '/00AAC000009aK3y', true,)

Now merchant number is null (but really blank with how VF handles null values) for the label which is fine as it's an optional label.

Optional label of the opened primary tab. If a label isn't specified, External Page displays.

Which looking at the documentation means that the default label for the record is called which is just the case number. (judging by the picture)

Just add this to your Viusalforce page to test if the getter setter is really doing anything.

<br>Merchant Number: {!merchantNumber}</br>

I have a strong feeling its just null/blank

I just tested on my end with our Console app by running this JavaScript commands:

sforce.console.openPrimaryTab(undefined, '/0014C0000afaK3y', true)
sforce.console.openPrimaryTab(undefined, '/0014C0000afaK3y', true,)

Equal the same thing the tab opening and using the record name (in this case an Account Name)

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.