• MrBungle
  • NEWBIE
  • 70 Points
  • Member since 2011

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 17
    Replies
Looking for a way to query by change set name to get a listing of all the components contained in an outbound or inbound change set. I cannot find any documentation. Surely something like this exists but I don't know the object name of it these could even be queried. Thank you!
 
Are there any textbook examples that Salesforce provides in their apex/visualforce documentation guides that outline how to have a pageblock table with pagination that remembers the values that users enter as they navigate through pages of records? From what I can see there is not. I have seen non-salesforce articles that describe how to achieve this. Any pointers to official Salesforce documents on how to do this would be greatly appreciated. Thank you!
 
I would like to not have to manually add all fields to be edited but instead just use the simple  <apex:detail> tag on a VF page. I also need to have other apex components such as a custom cancel button display so I can't use the /e url switch to set the record in edit mode because it won't use my page. Is there a way that my page can still use the <apex:detail> tag but display it in edit mode or is this strictly a read-only mode component?

Thank you.
 

I am troubleshooting System.LimitException: Too many SOQL queries: 101 errors in test classes. Is there a way that I can place i.e. system.debug('<current # on SOQL queries>'); to see where in my code that the SOQL queries jump in debug logs? Is there such a way to reference this global SOQL query count in my apex code?

 

Thank you.

We have a Live Agent chat button in our Customer Portal because only customers paying for our support can use Live Agent chat. We can get the customer portal user's Name, Email & Account and pre-populate a Pre-chat window but this hits the user with an unnecessary screen pop where they click a button to chat again. How can I set up the pre-chat window to just auto-submit? I have tried to programmatically click the submit button using javascript in window and body onloads and it does not work. I thought that I could maybe do this all in apex if I could use httprequest setmethod(‘POST’) but I couldn’t figure out how to do this or if it is even possible.

 

Does anyone know of a way that I can do this?

 

 

Pre-chat vf code:

<apex:page showHeader="false" standardController="User" extensions="NICP_Functions">

    <script>
        function clickBtn()
        {
            var btnSubmit = document.getElementById('prechat_submit');
            btnSubmit.click();
        }
    </script>

    <!-- This script takes the endpoint URL parameter passed from the deployment page and makes it the action for the form -->
    <script type="text/javascript">
        (function() 
        { 
            function handlePageLoad() 
            {
                var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
                document.getElementById('prechatForm').setAttribute('action', decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
            } 
            if (window.addEventListener) 
            {
                window.addEventListener('load', handlePageLoad, false);
            } 
            else 
            { 
                window.attachEvent('onload', handlePageLoad, false);
            }
        })();
    </script>
    
    <h1>Pre-chat Form</h1>
    <form method='post' id='prechatForm'>
    
        <style type="text/css">
            body {
                margin: 0 auto;
                padding: 0;
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
                font-size: 12px;
                color: #737373;
                line-height: 16px;
            }                    

            p {
                font-weight: bolder
            }
            
            td {
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
            }
            
            h1 {
                font-family: 'Trebuchet MS', Helvetica, sans-serif; 
            }

            .btnClass {
                font-family: 'Trebuchet MS', Helvetica, sans-serif; 
            }

        </style>

        <!-- Creates an auto-query for a matching Contact record’s Email field based on the value of the liveagent.prechat:Email field -->    
        <table border="0" width="400px">
            <tr>
                <td>
                    <b>Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Name' id='prechat_field' value='{!$User.FirstName} {!$User.LastName}' />          
                </td>
            </tr>
            <tr>
                <td>
                    <b>Email Address: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Email' width="500" value='{!$User.Email}' />
                </td>
            </tr>
            <tr>
                <td>
                    <b>Property Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Account' value='{!getAccountName}' />
                </td>
            </tr>
            <tr>
                <td>
                    
                </td>
                <td align="center">
                    <input type='submit' value='Request Chat' id='prechat_submit' class="btnClass" />
                </td>
            </tr>
        </table>

        <input type="hidden" name="liveagent.prechat.query:Email" value="Contact,Contact.Email" />         

    </form>


</apex:page>

 Pre-chat extension code

public with sharing class NICP_Functions 
{

    public String getAccountName{get; set;} 
    public User u;
    
    public NICP_Functions(ApexPages.StandardController controller) 
    {

        try 
        {
            User u = [SELECT Id, AccountId FROM User WHERE Id =: UserInfo.getUserId()];
            Account a = [SELECT Id, Name FROM Account WHERE Id =: u.AccountId];
            getAccountName = a.Name;
        }
        catch (Exception e){getAccountName = 'Please Specify';}   
        
    }
    

 

I have a VF page that populates 2 page block tables. One with Contact info and one with Account info based on a phone number parameter. I am using SOSL because the phone number param is in ########## format (with no hyphen delimiters) and when using the "IN PHONE FIELDS" declaration it finds the records. If I used SOQL I would have to figure out a way to have the matching work because most of the phone numbers in the DB are in (###) ###-#### format. 

 

I would like to have pagination in the page block tables which would be easy if it was using SOQL because I could utilize the OFFSET feature. Is there any way that I could mimic this feature using SOSL?

 

Thank you.

Basically, I need to be able to associate inbound call attributes with Cases created for them. Having this association is a good source for reporting on call duration vs case subject.

 

I have tested when the SoftPhone call terminates, SalesForce creates a Task record with the OwnerId of the call taker and writes values to the CallDurationInSeconds, CallType & CallObject fields on the Task. No inbound phone number is written though.

 

I have created a VF page & extension that I setup the SoftPhone to pop. This way I can have full control over the call taker's workflow from contact lookup/creation to Case creation. All associated with the inbound number. My problem is: I cannot associate the CallDurationInSeconds to the case or Task that gets created for that matter due to the lack of phone number on the Task.

 

Does anyone know of a way I can accomplish this? Is there a way that I can access the call durations/inbound phone number using Apex via the CTI?

 

 

Does Salesforce publish this statistic anywhere on-line or would it be in there best interest not to?

 

Any info/comments would be greatly appreciated!

 

Thank you.

 

 

I want to tidy up my triggers and follow a best practice I learned of at Dreamforce X. I learned that is is better to have just one trigger of one type (Before Insert, Before Update.. etc.). This way you can have control over the order of execution and just makes for less clutter.

 

I am trying to move all my trigger code to apex class methods and just call them from the trigger passing in the trigger.new, trigger.old objects (where applicable) as arguments. Seems easy and I've seen many articles on-line on this very subject. The problem is none of these articles show me how to use the trigger object that is passed to the method. Just the template. I need to iterate through the trigger in the method to make it work but in the for loop I get a save error when trying to save the class: (Save Error: Loop variable must be of type Object). Can someone help me figure out why? Thanks!

 

I get the error on line 18: "for (Asset a : newTrigger)" of the following code example.

 

public with sharing class My_TriggerHandler 
{

    private boolean m_isExecuting = false;
    
    public My_TriggerHandler(boolean isExecuting)
    {
    	m_isExecuting = isExecuting;
    }

    public boolean IsTriggerContext
    {
        get {return m_isExecuting;}
    }

    Public void AssetBeforeInsert(object[] newTrigger)
    {
        for (Asset a : newTrigger) 
        {

        }
    }

}

 

This is really frustrating!

 

I have setup Live Agent so that the button to initiate the pre-chat dialog, which is a visualforce page, is in our Customer Portal. We only want to give customer portal users access to Live Agent Chat. I need to retrieve the user’s name, email and account name so that the rep can have this referenced in the Live Agent Console chat. I have no problems getting the user’s name and email address using the typical declarative method:

 

<input type='text' size="40" name='liveagent.prechat:Name' id='prechat_field' value='{!$User.FirstName} {!$User.LastName}' /> 

 

And

 

<input type='text' size="40" name='liveagent.prechat:Email' width="500" value='{!$User.Email}' />

 

But I cannot, for the life of me, figure out what tag value to use to get the customer portal user’s account name. AccountId is a field on the User object that is populated for all active customer portal users. It seems access to this is restricted? I don’t now but it very frustrating none the less.

 

I have tried the following and they all do not pull the account name:

{!User.AccountId}

{!User.Account}

{!User.Account.Name}

{!User.Contact.Account}

{!User.Contact.Account.Name}

 

OK, So I figured that it’s time to create an extension class and strong arm the account name into the visualforce page using a SOQL query! Guess what? I can’t get the account name this way either.

 

PLEASE HELP!

 

 

Visualforce page syntax:

<apex:page showHeader="false" standardController="User" extensions="NICP_Functions">

    <!-- This script takes the endpoint URL parameter passed from the deployment page and makes it the action for the form -->
    <script type="text/javascript">
        (function() 
        { 
            function handlePageLoad() 
            {
                var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
                document.getElementById('prechatForm').setAttribute('action', decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
            } 
            if (window.addEventListener) 
            {
                window.addEventListener('load', handlePageLoad, false);
            } 
            else 
            { 
                window.attachEvent('onload', handlePageLoad, false);
            }
        })();
    </script>
    
    <apex:image url="{!$Resource.NI_CustPortal_Logo}" /><br /> 
    <h1>Pre-chat Form</h1>
    <form method='post' id='prechatForm'>
    
        <style type="text/css">
            body {
                margin: 0 auto;
                padding: 0;
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
                font-size: 12px;
                color: #737373;
                line-height: 16px;
            }                    

            p {
                font-weight: bolder
            }
            
            td {
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
            }
            
            h1 {
                font-family: 'Trebuchet MS', Helvetica, sans-serif; 
            }

            .btnClass {
                font-family: 'Trebuchet MS', Helvetica, sans-serif; 
            }

        </style>

        <!-- Creates an auto-query for a matching Contact record’s Email field based on the value of the liveagent.prechat:Email field -->    
        <table border="0" width="400px">
            <tr>
                <td>
                    <b>Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Name' id='prechat_field' value='{!$User.FirstName} {!$User.LastName}' />          
                </td>
            </tr>
            <tr>
                <td>
                    <b>Email Address: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Email' width="500" value='{!$User.Email}' />
                </td>
            </tr>
            <tr>
                <td>
                    <b>Property Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Account' value='{!User.Contact.Account.Name}' />
 </td> </tr> <tr> <td> </td> <td align="center"> <input type='submit' value='Request Chat' id='prechat_submit' class="btnClass" /> </td> </tr> </table> <input type="hidden" name="liveagent.prechat.query:Email" value="Contact,Contact.Email" /> </form> </apex:page>

 

extension class code:

public with sharing class NICP_Functions 
{

    public String getAccountName{get; set;} 
    private User u;
    
    public NICP_Functions(ApexPages.StandardController controller) 
    {
        this.u = (User)controller.getRecord(); 
        User u2 = [SELECT Id, AccountId FROM User WHERE Id =: u.Id];
        Account a = [SELECT Id, Name FROM Account WHERE Id =: u.AccountId];
        getAccountName = a.Name;
    }
}

 

 

Can someone help me figure out why this test class is failing?

 

The class was needed for a visualforce page that Customer Portal users will be hit with when they initiate a Live Agent Chat. The page is called a Pre-Chat page. I couldn't get access to the Customer Portal User's account name using the fields from the User standard controller.

 

Here's the Class:

public with sharing class NICP_Functions 
{

    public String getAccountName(){return strAccountName;}
    private User u;
    string strAccountName = '';
    
    public NICP_Functions(ApexPages.StandardController controller) 
    {
        this.u = (User)controller.getRecord(); 
        strAccountName = u.AccountId;
    }

}

 Here's the test class:

@isTest
private class TestNICP_Functions
{
    static testMethod void testPreChat()   
    {
        // PAGE REFERENCE
        Profile p = [SELECT Id FROM Profile WHERE Name =: 'Customer Portal Manager Standard'];
        User u = [SELECT id FROM User WHERE ProfileId =: p.Id AND IsActive = true AND AccountId != null LIMIT 1];
        PageReference ref = Page.NICP_PreChat;
        Test.setCurrentPage(ref);         
        NICP_Functions controller = new NICP_Functions(new ApexPages.StandardController(u));
        string an = controller.getAccountName();
    }
}

The error I get when I test the execution:

Class TestNICP_Functions 
Method Name testPreChat 
Pass/Fail Fail 
Error Message System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: User.AccountId 
Stack Trace Class.NICP_Functions.<init>: line 22, column 1
Class.TestNICP_Functions.testPreChat: line 22, column 1 

 

 

Thank you very much!

Hi, I'm new to the forum so I hope I'm asking this question in the proper group. 

 

Goal: We need to report on assets attached to cases. This gives us info on what products our support department is getting calls on. The asset field needs to be mandatory. 

 

Problem: There is a bug (or intentional functionality) that prevents our techs from choosing an asset on a case after the contact has been chosen. After the contact has been chosen the Asset lookup popup is blank. This is a major disruption in the call workflow because the first information gathered is the contact’s name. The next step is to get the Account name. After the Account is chosen then we ask for the Asset causing the problem. Because of issue the Asset field cannot be made mandatory and 99% of our cases have blank asset fields.

 

 Solution: I’m hoping that I can populate an apex:selectList with assets belonging to the selected Account on the Case.  Is this possible and if so, can someone point me in the right direction?

 

Thank you very much!

Looking for a way to query by change set name to get a listing of all the components contained in an outbound or inbound change set. I cannot find any documentation. Surely something like this exists but I don't know the object name of it these could even be queried. Thank you!
 
Are there any textbook examples that Salesforce provides in their apex/visualforce documentation guides that outline how to have a pageblock table with pagination that remembers the values that users enter as they navigate through pages of records? From what I can see there is not. I have seen non-salesforce articles that describe how to achieve this. Any pointers to official Salesforce documents on how to do this would be greatly appreciated. Thank you!
 

I am troubleshooting System.LimitException: Too many SOQL queries: 101 errors in test classes. Is there a way that I can place i.e. system.debug('<current # on SOQL queries>'); to see where in my code that the SOQL queries jump in debug logs? Is there such a way to reference this global SOQL query count in my apex code?

 

Thank you.

We have a Live Agent chat button in our Customer Portal because only customers paying for our support can use Live Agent chat. We can get the customer portal user's Name, Email & Account and pre-populate a Pre-chat window but this hits the user with an unnecessary screen pop where they click a button to chat again. How can I set up the pre-chat window to just auto-submit? I have tried to programmatically click the submit button using javascript in window and body onloads and it does not work. I thought that I could maybe do this all in apex if I could use httprequest setmethod(‘POST’) but I couldn’t figure out how to do this or if it is even possible.

 

Does anyone know of a way that I can do this?

 

 

Pre-chat vf code:

<apex:page showHeader="false" standardController="User" extensions="NICP_Functions">

    <script>
        function clickBtn()
        {
            var btnSubmit = document.getElementById('prechat_submit');
            btnSubmit.click();
        }
    </script>

    <!-- This script takes the endpoint URL parameter passed from the deployment page and makes it the action for the form -->
    <script type="text/javascript">
        (function() 
        { 
            function handlePageLoad() 
            {
                var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
                document.getElementById('prechatForm').setAttribute('action', decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
            } 
            if (window.addEventListener) 
            {
                window.addEventListener('load', handlePageLoad, false);
            } 
            else 
            { 
                window.attachEvent('onload', handlePageLoad, false);
            }
        })();
    </script>
    
    <h1>Pre-chat Form</h1>
    <form method='post' id='prechatForm'>
    
        <style type="text/css">
            body {
                margin: 0 auto;
                padding: 0;
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
                font-size: 12px;
                color: #737373;
                line-height: 16px;
            }                    

            p {
                font-weight: bolder
            }
            
            td {
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
            }
            
            h1 {
                font-family: 'Trebuchet MS', Helvetica, sans-serif; 
            }

            .btnClass {
                font-family: 'Trebuchet MS', Helvetica, sans-serif; 
            }

        </style>

        <!-- Creates an auto-query for a matching Contact record’s Email field based on the value of the liveagent.prechat:Email field -->    
        <table border="0" width="400px">
            <tr>
                <td>
                    <b>Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Name' id='prechat_field' value='{!$User.FirstName} {!$User.LastName}' />          
                </td>
            </tr>
            <tr>
                <td>
                    <b>Email Address: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Email' width="500" value='{!$User.Email}' />
                </td>
            </tr>
            <tr>
                <td>
                    <b>Property Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Account' value='{!getAccountName}' />
                </td>
            </tr>
            <tr>
                <td>
                    
                </td>
                <td align="center">
                    <input type='submit' value='Request Chat' id='prechat_submit' class="btnClass" />
                </td>
            </tr>
        </table>

        <input type="hidden" name="liveagent.prechat.query:Email" value="Contact,Contact.Email" />         

    </form>


</apex:page>

 Pre-chat extension code

public with sharing class NICP_Functions 
{

    public String getAccountName{get; set;} 
    public User u;
    
    public NICP_Functions(ApexPages.StandardController controller) 
    {

        try 
        {
            User u = [SELECT Id, AccountId FROM User WHERE Id =: UserInfo.getUserId()];
            Account a = [SELECT Id, Name FROM Account WHERE Id =: u.AccountId];
            getAccountName = a.Name;
        }
        catch (Exception e){getAccountName = 'Please Specify';}   
        
    }
    

 

Does Salesforce publish this statistic anywhere on-line or would it be in there best interest not to?

 

Any info/comments would be greatly appreciated!

 

Thank you.

 

 

I'm working on a CTI adapter.  I'm having some difficulty creating custom buttons on the SoftPhone that work when in Service Cloud Console.

I've read Gautam's very useful blog at http://success.salesforce.com/ideaView?id=08730000000YKxYAAW, and for testing purposes I'm trying simply to get a custom button on the Softphone to create a new case.  I have the URL of my button set (without the pretty spacing) to:

    javascript:
    if (typeof(srcUp) == 'function')
    {
        alert('in console');
        srcUp('/500/e?isdtp=vw');
        alert('done');
    }
    else
    {
        alert('not in console');
        parent.frames.location.replace('/500/e');
    }

It almost works:

  • When not in the Service Cloud Console, it works fine.  I get the "not in console" alert, and the new case panel comes up.
  • When in the Service Cloud Console starting with viewing a list of cases, it doesn't work.  I get both the "in console" and "done" alerts, but nothing else.
  • When in the Service Cloud Console starting with already viewing some other detail, it works in a strange way.  I get both the "in console" and "done" alerts, and the new case panel comes up in a tab alongside the details that I was already viewing.


What I want is for the button to have the same effect as if I had clicked the "New Case" button from the list of cases view.

I expect there's a simple answer to what I'm doing wrong, but I'm stuck for the moment.  Can anybody help, please?

Thanks,

James.

I want to tidy up my triggers and follow a best practice I learned of at Dreamforce X. I learned that is is better to have just one trigger of one type (Before Insert, Before Update.. etc.). This way you can have control over the order of execution and just makes for less clutter.

 

I am trying to move all my trigger code to apex class methods and just call them from the trigger passing in the trigger.new, trigger.old objects (where applicable) as arguments. Seems easy and I've seen many articles on-line on this very subject. The problem is none of these articles show me how to use the trigger object that is passed to the method. Just the template. I need to iterate through the trigger in the method to make it work but in the for loop I get a save error when trying to save the class: (Save Error: Loop variable must be of type Object). Can someone help me figure out why? Thanks!

 

I get the error on line 18: "for (Asset a : newTrigger)" of the following code example.

 

public with sharing class My_TriggerHandler 
{

    private boolean m_isExecuting = false;
    
    public My_TriggerHandler(boolean isExecuting)
    {
    	m_isExecuting = isExecuting;
    }

    public boolean IsTriggerContext
    {
        get {return m_isExecuting;}
    }

    Public void AssetBeforeInsert(object[] newTrigger)
    {
        for (Asset a : newTrigger) 
        {

        }
    }

}

 

This is really frustrating!

 

I have setup Live Agent so that the button to initiate the pre-chat dialog, which is a visualforce page, is in our Customer Portal. We only want to give customer portal users access to Live Agent Chat. I need to retrieve the user’s name, email and account name so that the rep can have this referenced in the Live Agent Console chat. I have no problems getting the user’s name and email address using the typical declarative method:

 

<input type='text' size="40" name='liveagent.prechat:Name' id='prechat_field' value='{!$User.FirstName} {!$User.LastName}' /> 

 

And

 

<input type='text' size="40" name='liveagent.prechat:Email' width="500" value='{!$User.Email}' />

 

But I cannot, for the life of me, figure out what tag value to use to get the customer portal user’s account name. AccountId is a field on the User object that is populated for all active customer portal users. It seems access to this is restricted? I don’t now but it very frustrating none the less.

 

I have tried the following and they all do not pull the account name:

{!User.AccountId}

{!User.Account}

{!User.Account.Name}

{!User.Contact.Account}

{!User.Contact.Account.Name}

 

OK, So I figured that it’s time to create an extension class and strong arm the account name into the visualforce page using a SOQL query! Guess what? I can’t get the account name this way either.

 

PLEASE HELP!

 

 

Visualforce page syntax:

<apex:page showHeader="false" standardController="User" extensions="NICP_Functions">

    <!-- This script takes the endpoint URL parameter passed from the deployment page and makes it the action for the form -->
    <script type="text/javascript">
        (function() 
        { 
            function handlePageLoad() 
            {
                var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
                document.getElementById('prechatForm').setAttribute('action', decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
            } 
            if (window.addEventListener) 
            {
                window.addEventListener('load', handlePageLoad, false);
            } 
            else 
            { 
                window.attachEvent('onload', handlePageLoad, false);
            }
        })();
    </script>
    
    <apex:image url="{!$Resource.NI_CustPortal_Logo}" /><br /> 
    <h1>Pre-chat Form</h1>
    <form method='post' id='prechatForm'>
    
        <style type="text/css">
            body {
                margin: 0 auto;
                padding: 0;
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
                font-size: 12px;
                color: #737373;
                line-height: 16px;
            }                    

            p {
                font-weight: bolder
            }
            
            td {
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
            }
            
            h1 {
                font-family: 'Trebuchet MS', Helvetica, sans-serif; 
            }

            .btnClass {
                font-family: 'Trebuchet MS', Helvetica, sans-serif; 
            }

        </style>

        <!-- Creates an auto-query for a matching Contact record’s Email field based on the value of the liveagent.prechat:Email field -->    
        <table border="0" width="400px">
            <tr>
                <td>
                    <b>Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Name' id='prechat_field' value='{!$User.FirstName} {!$User.LastName}' />          
                </td>
            </tr>
            <tr>
                <td>
                    <b>Email Address: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Email' width="500" value='{!$User.Email}' />
                </td>
            </tr>
            <tr>
                <td>
                    <b>Property Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Account' value='{!User.Contact.Account.Name}' />
 </td> </tr> <tr> <td> </td> <td align="center"> <input type='submit' value='Request Chat' id='prechat_submit' class="btnClass" /> </td> </tr> </table> <input type="hidden" name="liveagent.prechat.query:Email" value="Contact,Contact.Email" /> </form> </apex:page>

 

extension class code:

public with sharing class NICP_Functions 
{

    public String getAccountName{get; set;} 
    private User u;
    
    public NICP_Functions(ApexPages.StandardController controller) 
    {
        this.u = (User)controller.getRecord(); 
        User u2 = [SELECT Id, AccountId FROM User WHERE Id =: u.Id];
        Account a = [SELECT Id, Name FROM Account WHERE Id =: u.AccountId];
        getAccountName = a.Name;
    }
}

 

 

Can someone help me figure out why this test class is failing?

 

The class was needed for a visualforce page that Customer Portal users will be hit with when they initiate a Live Agent Chat. The page is called a Pre-Chat page. I couldn't get access to the Customer Portal User's account name using the fields from the User standard controller.

 

Here's the Class:

public with sharing class NICP_Functions 
{

    public String getAccountName(){return strAccountName;}
    private User u;
    string strAccountName = '';
    
    public NICP_Functions(ApexPages.StandardController controller) 
    {
        this.u = (User)controller.getRecord(); 
        strAccountName = u.AccountId;
    }

}

 Here's the test class:

@isTest
private class TestNICP_Functions
{
    static testMethod void testPreChat()   
    {
        // PAGE REFERENCE
        Profile p = [SELECT Id FROM Profile WHERE Name =: 'Customer Portal Manager Standard'];
        User u = [SELECT id FROM User WHERE ProfileId =: p.Id AND IsActive = true AND AccountId != null LIMIT 1];
        PageReference ref = Page.NICP_PreChat;
        Test.setCurrentPage(ref);         
        NICP_Functions controller = new NICP_Functions(new ApexPages.StandardController(u));
        string an = controller.getAccountName();
    }
}

The error I get when I test the execution:

Class TestNICP_Functions 
Method Name testPreChat 
Pass/Fail Fail 
Error Message System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: User.AccountId 
Stack Trace Class.NICP_Functions.<init>: line 22, column 1
Class.TestNICP_Functions.testPreChat: line 22, column 1 

 

 

Thank you very much!

Hi, I'm new to the forum so I hope I'm asking this question in the proper group. 

 

Goal: We need to report on assets attached to cases. This gives us info on what products our support department is getting calls on. The asset field needs to be mandatory. 

 

Problem: There is a bug (or intentional functionality) that prevents our techs from choosing an asset on a case after the contact has been chosen. After the contact has been chosen the Asset lookup popup is blank. This is a major disruption in the call workflow because the first information gathered is the contact’s name. The next step is to get the Account name. After the Account is chosen then we ask for the Asset causing the problem. Because of issue the Asset field cannot be made mandatory and 99% of our cases have blank asset fields.

 

 Solution: I’m hoping that I can populate an apex:selectList with assets belonging to the selected Account on the Case.  Is this possible and if so, can someone point me in the right direction?

 

Thank you very much!

Hi all,

 

You are gonna like this one!

 

I am getting an error on Eclipse 3.4.2 that restricts me to save, synchronize and/or deploy my project. It reads:

 

"Unable to fetch and save Force.com components to project:

 The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later. (ALREADY_IN_PROCESS)"

 

Has anyone seen this error before? I have wait for 15 minutes (my max waiting capacity :( ), tried to refresh, deploy, save... but this error is not letting me go anywhere.

 

Suggestions are welcome

 

Alex

  • February 16, 2010
  • Like
  • 0