• SFDC-NOOB
  • NEWBIE
  • 115 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 47
    Replies

Hello,

 

I'm having issues with a trigger that I wrote to prevent users from saving cases with adding the Account Name and Contract ID.  Users can't submit record with a blank Account Name and Contract ID but they are able to submit records with blank Account Name and have a Contract ID.

 

Here's my code:

 

trigger PopulateSPIDContractIdonCase on Case (before insert, before update) {

    Profile p = [SELECT Id from Profile where Name='System Administrator'];
        
        if(System.Trigger.IsUpdate||System.Trigger.IsInsert)
        {
            for (Case c : trigger.new)
            
                if (UserInfo.getProfileId() != p.Id && (c.Reason__c == 'Recon Related') && (c.Account == NULL) && (c.Contract_ID__c == NULL))
                {
                c.addError('  Please enter a Contract ID and Account Name.');
                }
        }
       
}

 

I have a requirement to implement short polling using JS Remoting.  I've looked into long polliing using the streaming API but it does not seem like a reliable solution for my use case.  I would like to poll the server every X minutes.  Is there a limit to the number of SOQL queries that can be executed?
I am using javascript remoting.  I have a situation where I need remote actions to execute in order.

The problem I am running into is the second remote action executes prior to the first one finishing.  Seems like I've tried everything!  Since remote actions are asynchronous, is it possible to execute them in order?  What is the best way to do so?


    Visualforce.remoting.Manager.invokeAction(
      '{!$RemoteAction.ChoptankRates.method1}',
      document.getElementById('var1').value,
                   
      function(result, event) {
        document.getElementById('var1').value = result[0].somevalue;
       
        //Execute second remote action now.
      }
    );
    Visualforce.remoting.Manager.invokeAction(
      '{!$RemoteAction.ChoptankRates.method2}',
      document.getElementById('VAR1').value,

      function(result, event) {
        //do something here
      }
    );
The developer console on instance cs11 has the following JS error:
"Failed to create createContainerMember for conatinerId=undefined: null is not a valid containerId."

I can create triggers and classes but cannot save the body.  The error pops up every minute or so.  Salesforce, please fix

Seems the error is related to this:
https://success.salesforce.com/issues_view?id=a1p300000008XvGAAU
 
I am attempting to sort a list based on user clicking columns on visualforce page. Seems like the comparable interface is the best way to do this.

I can sort using static variables but it's messy. I would like to have dynamic variable to compare the list elements; however, I am receiving an error.  Any help is greatly appreciated.

public class loadsort implements Comparable  
    {  
      public parseUtility.load load {get; set;}   
        
      public loadsort(parseutility.load ld)  
      {  
        load = ld;  
      }  
        
      public Integer compareTo(Object VLoad)  
      {  
        loadsort LoadToComp = (loadsort)VLoad;  
        
        if(Load.get(comparefield) > Loadtocomp.load.get(comparefield))  
          return SortOrder.equals('asc') ? 1 : 0;  
        else
          return sortOrder.equals('asc') ? 0 : 1;
      }
    } 

This is the error:::::: Method does not exist or incorrect signature: [ParseUtility.load].get(String)
Hi all,

I am trying to center a Google map on a location that is entered by the user.  A web service passes the city and state and retrieves the coordinates of said location and returns them to the controller.  I have a 'Get Map' button that calls a javascript function which should display and center the map using the coordinates from the controller.  The map is centered in the Indian Ocean. . . .

Now when I call the properties using outputtext tags in visualforce, they hold the value of the coordinates; however, when I call the properties in a JS function, they are null.  I have very little experience with JS.  Thanks in advance.

When debugging the JS, I get an error: *Uncaught ReferenceError: myLatlng is not defined.

----------------------------------------------------------------------------------------
Here is the function that my 'Get Map' button invokes:

<script>      
        function initialize() {
        var lat = '{!lng}';   // SHOULD HOLD CORRECT LNG BUT IS NULL
        var lng = '{!lat}';   // SHOULD HOLD CORRECT LAT BUT IS NULL
        var myLatlng = new google.maps.LatLng(lat,lng);
        var mapOptions = ({
        zoom: 10,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
   
    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
}
</script>

<apex:form id="frm">
   
    <apex:pageblock id="pblck">
    <apex:pageblocksection id="pbsectn" >
    <apex:inputtext value="{!city}" label="City" required="True"/>
    <apex:selectlist value="{!states}" multiselect="false" size="1" label="State" required="True">
        <apex:selectoptions value="{!items}"/>
    </apex:selectlist>
    </apex:pageblocksection>
    <apex:pageblockbuttons >
        <apex:commandButton action="{!submitRequest}" value="Sumbit Request" rerender=""/>
        <apex:commandbutton onclick="initialize()" value="Get Map" rerender="map-canvas"/>
    </apex:pageblockbuttons>
   
   
    <apex:pageblocksection id="results">
    <apex:outputtext value="{!lat}" id="lat"/>
    <apex:outputtext value="{!lng}" id="lng"/>   //CORRECT LAT AND LNG
    </apex:pageblocksection>
   
</apex:pageblock>
   
    <div id="map-canvas" style="width:100%;height:300px"></div>   // DOES NOT CENTER WITH CORRECT LAT AND LNG
    </apex:form>


------------------------------------------------------------------------------------------------
This is my controller for the visualforce page:

public decimal lat{get;set;}
public decimal lng{get;set;}

public decimal getlat(){
        return lat;
    }
   
    public void setlat(decimal lat) {
        this.lat = lat;
    }
    public decimal getlng() {
           return lng;
        }
         
    public void setlng(decimal lng) {
        this.lng = lng;
    }

public pagereference submitRequest(){
        googlenearbystorages gns = new googlenearbystorages(type, city, states, zipcode);
        lat = decimal.valueof(gns.latitude);
        lng = decimal.valueof(gns.longitude);       
    return null;
    }

I have a visualforce page that displays a report chart and table in a tab. In a separate tab I have a list with some data. Inline editing is enabled for the list. When I double click the the field I would like to edit (in this case status__c), nothing happens. When I remove the reportchart component from the other tab, I can double click and edit just fine. Any help is greatly appreciated. Thanks in advance.


<apex:tab label="Report">
                <apex:pageblock title="Quote Count">
                    <apex:pageblocktable value="{!summaries}" var="summary">
                        <apex:column headervalue="Sales Rep">
                            {!summary.name}<br/>
                        </apex:column>
                        <apex:column headervalue="Quote Count">
                            {!summary.Quantity}
                        </apex:column>
                        <apex:column headervalue="Total">
                           <apex:outputtext value="{0, number,$###,###,##0}"> <apex:param value="{!summary.total}"/> </apex:outputtext>
                        </apex:column>
                    </apex:pageblocktable>
                    <analytics:reportChart reportId="00OZ0000000GcrL" size="medium"></analytics:reportChart>  <!--Breaks inline editing!  -->
                </apex:pageblock>
                </apex:tab>

Separate tab starts here. . .
<apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Status" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="status__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!q.Status__c}">
                <apex:inlineEditSupport showOnEdit="saveButton, cancelButton"   <!-- Broken from reportchart in first tab -->
                        hideOnEdit="editButton" event="ondblclick"
                        changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
                </apex:outputfield>
                </apex:column>

Hello apex experts,

 

I have a field on the account object that updates when the account is edited.  When the record is edited individually, the correct value gets written to the field.  When I use the data loader . . . One value applies to all records.  Here is my trigger, please advise.

 

trigger Populate_Transfer_Manager on Account (before insert, before Update) {   
   
    list<id> aid = new list<id>();
    for(account a: trigger.new){           
        aid.add(a.ownerid);
    }
    
list<user> managers = new list<user>();
    managers = [select managerid from user where id in: aid];
   

set<id> manid = new set<id>();                             
    for(user u: managers){
        manid.add(u.managerid);
    }
   

for(account a: trigger.new){        
    for(id i: manid){           
            a.transfer_manager__c = i;       
        }
    }
}

Hello,

 

My VP of business development would like to be BCC'd on emails to specific customers.  Our sales reps use Salesforce to outlook API.  Is it possible to develop a trigger that would fire and send the email to him when the record is uploaded from outlook to the customer account in Salesforce?  Any direction or help with the logic is greatly appreciated.

 

Thanks,

J

Greetings,

 

I have a custom controller and visualforce page.  Long story short, one of the fields I am querying is a formula field that I would like to display on the visualforce page.  No values are displayed.  Any thoughts on how I can get the formula field to populate the value?

 

Here is the method from my controller:

"team_number__c" is the formula field that will not populate on the visualforce page.

 

public list<MyCarrier> getCarriers(){
string sortFullExp = sortfield + ' ' + sortDirection;
carriers.clear();
for(carrier__c c : database.query('select team_number__c, insurance_requested__c, load_date_time__c, date_submitted__c, lastmodifiedby.alias, id, team__c, references__c, requester__c, fraud_websites__c, Insurance_received__c, conditional_letter__c, contract__c, MC_Number__c, compliance_action__c, attachment__c, name from carrier__c where team__c != NULL order by ' + sortFullExp ))
{
carriers.add(new myCarrier(c));
}
return carriers;
}

 

 

 

This is the formula that populates "team_number__c":::

if(Team__c = "t9chop1", "Team 9", if(Team__c = "t1chop2", "Team 1",""))

Hello,

 

I am attempting to change the color of names in a list based on whether the ID in the field "Team__c" on the carrier object matches any ID in the list of users. My controller is returning the color one time and this color applies to all records (See debug log). All values in the list are blue, some should be red. Any help is greatly appreciated, thank you in advance.

 

 

Visualforce:::

 

<apex:pageblocktable value="{!carriers}" var="c">

    <apex:column headervalue="Carrier">

        <font color="{!color2}">

            <apex:outputtext value="{!c.name}"/>

        </font>

    </apex:column>

 

 

 

Controller:::

 

public string getcolor2() {

    list<carrier__c> carriers = [select team__c from carrier__c where team__c != NULL];

 

    list<user> users= new list<user>();

        users = [select id from user where userrole.name = 'Executive'];

            set<string> uid = new set<string>();

            for(user us: users){

                uid.add(us.id);

            }

 

    string color = 'red';

 

    for(carrier__c car: carriers){

        system.debug('*****List of carriers: ' + carriers);

        system.debug('*****List of users: ' + uid);

        system.debug('*****Current carrier= '+car);

        if(uid.contains(car.team__c) ){

            color='blue';

            system.debug('***** Set color to:'+color);  

            }

    }

    system.debug('***** Returning color: ' + color);

    return color;

}

 

 

Debug Log::::

 *****List of carriers: (Carrier__c:{Team__c=005U0000001D3E5IAK,      Id=a0HJ0000003bl8nMAA}, Carrier__c:{Team__c=005J0000001EEIHIA4, Id=a0HJ0000003bitnMAA}, Carrier__c:{Team__c=005U0000001BHRKIA4, Id=a0HJ0000003eD64MAE})

 

 *****List of users: {005U0000001D3E5IAK}

 *****Current carrier= Carrier__c:{Team__c=005U0000001D3E5IAK, Id=a0HJ0000003bl8nMAA}

 ***** Set color to:blue

 

*****List of users: {005U0000001D3E5IAK}

*****Current carrier= Carrier__c:{Team__c=005J0000001EEIHIA4, Id=a0HJ0000003bitnMAA}

 

*****List of users: {005U0000001D3E5IAK}

*****Current carrier= Carrier__c:{Team__c=005U0000001BHRKIA4, Id=a0HJ0000003eD64MAE}

 

***** Returning color: blue

Greetings,

 

I am attempting to change the color of text in a visualforce page.  I am doing the logic in the contoller and passing the variable to the VF page.  The problem is I am comparing a lookup field to a set of IDs.  If the ID is not in the list, I want to change the color.  I think I can get there with a nested for loop but it is not best practice.  Any input on how to acheive this is greatly appreciated.

 


public String getcolor1(){
LIST<user> users= new list<user>();
users = [select id, name from user where userrole.name = 'Executive' or userrole.name='Ops Team 8'];
set<id> uid = new set<id>();

for(user us: users){
uid.add(us.id);
}

 

String color='red';
list<carrier__c> Ids = [select id, team__c from carrier__c where team__c != NULL];
//system.debug('***** cid = '+cid);
system.debug('***** uid = '+uid);
system.debug('***** Ids = '+Ids);

for(carrier__c car: ids){
if(car.team__c ! NOT IN: uid){   //  This is incorrect logic.  comparing an ID (lookup field) to a set of IDs.  Perhaps I should have a nested for loop?
color='blue';
}
// }
}
return color;
}

 

 

 

Currently everything in the list is blue and some should be red.

Greetings,

 

Need help with logic--

 

I have a work flow rule that stamps a "Date submitted" field when a record enters the approval process.  I want to fire a trigger to send an email to a specified user 4 hours after the date submitted field is stamped with the current date/time.  With that said, I looked into an asynchronous trigger to send the email but I don't think this is the best option since I cannot control the time the trigger fires.  Does anyone have a recommendation on how I can achieve this?

 

Thanks in advance!

Is it possible to subquery tasks?  I'd like to pull accounts that do not have an open task.

 

This is what I have:

 

for(account a: [select id, Name, ownerid, lastactivitydate FROM ACCOUNT WHERE ID IN (SELECT ACCOUNTID FROM task WHERE STATUS != 'NOT STARTED') AND lastactivitydate <:lastedit AND type = 'Active Opportunity' AND LastModifiedDate <:lastedit and ownerID !=: userinfo.getuserid() and LASTACTIVITYDATE!= NULL ORDER BY LastActivityDate Desc limit 150]) {
accountlist.add(new aAccount(a));
}

 

I am throwing this error:

Compile Error: Entity 'task' is not supported for semi join inner selects at line 35 column 24

 

Is there another way to pull all accounts that do not have an open task?

Hello,

 

I am trying to get coverage on my controller.  I am at 55% but I can't seem to access the wrapper class.  Please advise.  Lines in red are not covered.  My code is as follows:

Thank you in advance.

 

 

*****************************************************************************CONTROLLER*****************************************************************

public class UpForGrabs{

date d = date.today();
date LastTdate = date.today().addDays(-90);
date taskduedate = date.today().adddays(7);
date OppClosedate = date.today().addDays(14);

public List<aAccount> accountList{get; set;}
public List<opportunity> oppsList{get;set;}
public List<contact> contactList {get;set;}
public boolean limitcheckbox{get;set;}



public List<aAccount> getAccounts() {

if(accountList == null) {

accountList = new List<aAccount>();

for(account a: [select id, Name, type, ownerid, lastmodifieddate FROM ACCOUNT WHERE lastactivitydate <:LastTDate AND type = 'Active Opportunity' AND LastModifiedDate <:d ORDER BY LastModifiedDate Desc limit 1000]) {

 

accountlist.add(new aAccount(a));

}
}
return accountList;
}

public list<opportunity> getOpps(){
oppsList = [SELECT AccountId, OwnerId FROM Opportunity WHERE Stagename != 'Closed Lost' AND Stagename != 'Closed Won'];
return oppsList;
}

public list<contact> getcontacts(){
contactList = [Select accountid, ownerid FROM Contact];
return contactList;
}

public PageReference processSelected() {

List<account> selectedaccounts = new List<account>();

 

for(aAccount aAcct: getAccounts()) {
if(aAcct.selected == true) {
selectedAccounts.add(aAcct.acct);
}
}

 

System.debug('These are the selected accounts...');

for(account acct: selectedaccounts) {
acct.Ownerid = UserInfo.getUserId();
system.debug(acct);
update acct;

for(opportunity o: getOpps()){
if(o.accountid == acct.id){
o.ownerid = userinfo.getuserid();
update o;

system.debug(o);
}
}

for(contact c: getContacts()){
if(c.accountid == acct.id){
c.ownerid = userinfo.getuserid();
system.debug(c);
update c;
}
}

task t = new task(ownerid = userinfo.getuserid(),whatid=acct.id, subject = 'Call', Priority = 'Normal', Status= 'Not Started',activitydate = taskduedate );
insert t;
}
accountList = null;
return null;
}

 

//THIS IS MY WRAPPER CLASS


public class aAccount {
public account acct {get; set;}
public Boolean selected {get; set;}

 

public aAccount (Account a) {

acct = a;
selected = false;
}

}
}

 

 

**********************************************************************************TEST CLASS*********************************************************************************

 

@istest
public class Testupforgrabs{
public static TestMethod Void Testupforgrabs(){
    date mydate = date.today();
    
    pagereference pageRef = page.upforgrabs;
    Test.setCurrentPage(pageRef);

        upforgrabs UFG = new upforgrabs();
        
        account a = new account( Name='Test',phone='4109011267',macro_industry__c='Construction',custom_account_source__c='Referral',preferred_mode_s__c='Van');
        insert a;
                
        a.ownerid = userinfo.getuserid();
        update a;
        
        contact c = new contact(accountid=a.id,firstname='John',lastname='Doe');
        insert c;
        
        if(c.accountid == a.id){
        c.ownerid = userinfo.getuserid();
        }
        update c;
        
        task t = new task(ownerid=userinfo.getuserid(), whoid=c.id,subject='Email',whatid=a.id,priority='Normal',Status='Not started');
        insert t;
        
        opportunity opp = new opportunity(ownerid=userinfo.getuserid(), accountid=a.id, name = 'TestOpp',stagename='Discovered',closedate=mydate);
        insert opp;
        
        UFG.getaccounts();
        UFG.getcontacts();
        UFG.getOpps();
        UFG.processselected();
}
}

Greetings,

 

I can't seem to figure out why I am getting the following error.  I have the "Name" field in my test class and have confirmed it is not NULL using system.assertvalue.  What am I doing wrong?  Thank you in advance for your help!!!

 

 

Error Message:::::::: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name]

Stack Trace::::::   Class.multirecords.save: line 20, column 1
                              Class.TestMultiRecords.TestMultiRecords: line 36, column 1

 

 

 

 

 

*************************************************************************TEST CLASS******************************************************

 

 

@istest
public class TestMultiRecords{
    
    public static testMethod void TestMultiRecords(){
    date mydate = date.today();
    string accountnametest = 'TestMultiRec';
    string opportunitynametest = 'testOpp';
    string firstnametest = 'John';
    string lastnametest = 'Doe';
        
        PageReference pageRef = Page.multirecords;
        Test.setCurrentPage(pageRef);
        
        multirecords Controller = new multirecords();
        
        account a = new account(Name = 'TestMultiRec',phone='4109011267',macro_industry__c='Construction',custom_account_source__c='Referral',preferred_mode_s__c='Van');
        insert a;
        system.assertequals(accountnametest, a.name);
        
        contact c = new contact(accountid=a.id,firstname='John',lastname='Doe');
        insert c;
        system.assertequals(firstnametest, c.firstname);
        system.assertequals(lastnametest, c.lastname);
        
        task t = new task(whoid=c.id,subject='Email',whatid=a.id,priority='Normal',Status='Not started');
        insert t;
        system.assertequals(c.id,t.whoid);
        
        opportunity o = new opportunity(accountid=a.id,name='testOpp',stagename='Discovered',closedate=mydate);
        insert o;
        system.assertequals(opportunitynametest,o.name);
           
        controller.getaccountlist();
        controller.getcontactlist();        
        controller.cancel();
        controller.save();          //Error here
        
    }
}

 

 

 

*****************************************************************Controller**********************************************************************

 

public class multirecords {

public Account A {get; set;}
Public Task T {get; set;}
Public Opportunity O {get; set;}
string inputstring{get;set;}


public multirecords()
{
A = new account();
T = new task();
O = new opportunity();
}


public PageReference save()
{

insert a;


T.whatid = A.id;
insert T;

O.Accountid = A.id;
insert O;

/* Redirects the page to the new account
*/

return new PageReference('/'+A.id);
}

public PageReference Cancel()
{
return new PageReference('/001/o');
}

/* Used for the Account list at the end of the visualforce page.
*/
public List<Account> getAccountList() {
return [select name, Type FROM account WHERE Owner.id =: userinfo.getuserid() AND Type != 'Disqualified' AND Type != 'Recycle' ORDER BY Name];
}

/* Used for the Contact list at the end of the
VisualForce page
*/

public List<Contact> getContactList() {
return [select name, title, email, phone FROM contact WHERE owner.id =: userinfo.getuserid()];
}

}

 

Greetings,

 

I am at 68% and I can't seem to get up to 75% code coverage for my test class.  The code in red is NOT covered.  My code is as follows.

 

Note: I get the following error when testing:::: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name]      //(LINE 17)

 

 

 

**********************************************Visualforce page**************************************

<apex:page controller="multirecords" tabstyle="Account">

<div style="font-size:12px">
Account Edit
</div>
<div style="font-size: 24px">
<B>New Account</B><br></br>
</div>

<apex:form id="TheForm">

<apex:pageblock >
<head>
<style>
div.pbSubheader{
font-size:13px;
}
</style>
</head>

<apex:pageMessages ></apex:pageMessages>
<apex:pageblocksection title="Account Information">
<apex:inputField Value="{!A.name}" required="true" taborderhint="1"/>
<apex:inputfield Value="{!A.type}" taborderhint="7"/>
<apex:inputfield value="{!A.phone}" required="true" taborderhint="2"/>
<apex:inputField value="{!A.Macro_Industry__c}" required="true" taborderhint="8"/>
<apex:inputfield value="{!A.billingstreet}" taborderhint="3"/>
<apex:inputfield value="{!A.Micro_Industry__c}" required="true" taborderhint="9"/>
<apex:inputfield value="{!A.billingcity}" taborderhint="4"/>
<apex:inputfield value="{!A.Custom_Account_Source__c}" required="true" taborderhint="10"/>
<apex:inputfield value="{!A.billingstate}" taborderhint="5"/>
<apex:inputfield value="{!A.website}" taborderhint="11"/>
<apex:inputfield value="{!A.Preferred_Mode_s__c}" required="true" taborderhint="6"/>
<apex:inputfield value="{!A.Customer_Type__c}" taborderhint="12"/>
<apex:inputfield value="{!A.description}" taborderhint="13"/>
</apex:pageblocksection>


<apex:pageblocksection title="Activity Information">
<apex:inputfield value="{!T.subject}" required="true" taborderhint="14"/>
<apex:inputfield value="{!T.Activitydate}" required="true" taborderhint="16"/>
<apex:inputfield value="{!T.status}" taborderhint="15"/>
<apex:inputfield value="{!T.description}" taborderhint="17"/>
</apex:pageblocksection>


<apex:pageblocksection title="Opportunity Information">
<apex:inputfield value="{!O.name}" taborderhint="18"/>
<apex:inputfield value="{!O.stagename}" taborderhint="20"/>
<apex:inputfield value="{!O.closedate}" taborderhint="19"/>
<apex:inputfield value="{!O.amount}" taborderhint="21"/>
</apex:pageblocksection>
<div align="center">
<apex:commandbutton value="Save Record" action="{!save}" rerender="TheForm"/>
</div>
</apex:pageblock>
</apex:form>


</apex:page>

 

***********************************************************************************CONTROLLER*******************************************************************************************

public class multirecords {

public Account A {get; set;}
Public Task T {get; set;}
Public Opportunity O {get; set;}

public multirecords()
{
A = new account();
T = new task();
O = new opportunity();
}

public PageReference save()
{

insert A;       //Line 17 -- The aforementioned error occurs here.

insert T;
T.whatid = A.id;

insert O;
O.Accountid = A.id;

return new PageReference('/'+A.id);
}

public PageReference Cancel()
{
return new PageReference('/001/o');
}

}

 

 

*****************************************************************************************TEST CLASS*******************************************************************************

@istest

public class TestMultiRecords{
public static testMethod void TestMultiRecords(){

PageReference pageRef = Page.multirecords;
Test.setCurrentPage(pageRef);

multirecords Controller = new multirecords();


Account a = new account(Name='Testmultirecord',phone='4109011267',macro_industry__c='Construction',custom_account_source__c='Referral',preferred_mode_s__c='Van');
insert a;

task t = new task(subject='testmultirecord');
insert t;

controller.cancel();
controller.save();

}
}

 

 

 

Greetings,

 

I am attempting to display an image on a visualforce page if account.dq_reason__c == 'Out of Business'

 

The image displays but the problem is it ALWAYS displays.  I only need it to display when the dq_reason is "Out of Business".  Seems like a simple task but I don't know what I am doing wrong.  Any help is greatly appreciated.  Thanks in advance.

 

****************************************************VisualForce Page*************************************************************

 

<apex:page standardController="Account" showHeader="true"  >

<img src="{!$Resource.Black_Box}" width="600" height="60" rendered ="{!account.DQ_Reason__c =='Out of Business'}" />


<apex:detail relatedList="false" title="true"/>


<apex:relatedList subject="{!account}" list="contacts" />


<apex:relatedList subject="{!account}"
list="opportunities" />


<apex:relatedList subject="{!account}"
list="OpenActivities" />


<apex:relatedList subject="{!account}"
list="NotesAndAttachments" />


</apex:page>

Greetings,

 

I am attempting something pretty simple.  I have a list of accounts displayed and I want to make the account name clickable so that it goes to the corresponding record.  I have the code implemented but when I click the account name, it goes to a page that says "ERROR URL NO LONGER EXISTS."  Your help is greatly appreciated.  My code is as follows:

 

***************************************VF Page******************************************************

 

<apex:page controller="NewController" >

<apex:form id="theForm">

<apex:pageBlock title="{!$User.FirstName}'s Accounts">

<apex:commandButton value="Save" action="{!save}" rerender="theForm,msg"/>
<apex:commandbutton value="Edit" action="{!edit}" rerender="theForm"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
<br></br><br></br><b>Note: Selecting "Recycle will auto-populate the DQ Reason ("No Longer Wish to Pursue").</b><p></p>

<apex:pageblocktable value="{!myaccounts}" var="acct">
<apex:column headervalue="Account">
<apex:outputlink value="/!{acct.id}">{!acct.Name}</apex:outputlink>
<apex:inputField value="{! acct.Name}" rendered="{!IsEditEnabled}"/>
</apex:column>


<apex:column headervalue="Recycle">
<apex:outputField value="{!acct.type}"/><br/>
<apex:inputfield value="{! acct.type}" rendered="{!IsEditEnabled}"/>
</apex:column>

<apex:column headervalue="DQ Reason">
<apex:outputField value="{!acct.DQ_Reason__c}" />
</apex:column>

</apex:pageblocktable>

<apex:pageMessages id="msg"/>
<p></p> <B> Note: Selecting "Recycle will auto-populate the DQ Reason ("No Longer Wish to Pursue").</B><br/><br/>
<apex:commandButton value="Save" action="{!save}" rerender="theForm,msg"/>
<apex:commandbutton value="Edit" action="{!edit}" rerender="theForm"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageblock>
</apex:form>
</apex:page>

 

 

***********************************************************Controller*********************************************************************

 

public class NewController {

public List<Account> myAccounts;
public Boolean isEditEnabled;

//Constructor called when page is accessed.
public NewController(){
myAccounts = new List<Account>();
isEditEnabled = false;
}

public List<Account> getMyAccounts(){
myAccounts = [select Id,name,type, dq_reason__c from Account WHERE type != 'Customer' and type != 'Disqualified' and (owner.id =: userinfo.getuserid()) order by name];
return myAccounts;
}

public PageReference edit() {
isEditEnabled = true;

return null;
}

public PageReference cancel() {
iseditenabled = false;
return null;
}

public PageReference save() {

for (account a: myaccounts){
if(a.type == 'Disqualified'){
apexpages.addmessage(new apexpages.message(ApexPages.severity.ERROR,'Invalid entry, "Disqualified" option not yet supported. Contact your administrator.'));

return null;
}
if(a.type == 'Recycle'){
a.dq_reason__c = 'No Longer Wish to Pursue';
}
else if(a.type != 'Recycle'){
a.dq_reason__c = '';
}

}
update myAccounts;
isEditEnabled = false;
return null;
}

public Boolean getIsEditEnabled(){
return isEditEnabled;
}
}

Greetings,

 

I have a dependent picklist that I need some validation on.  When "Disqualified" or "Recycled" is selected from the controlling field, I want the dependent field to be required.  The dependent field is only editable when "Disqualified" or "Recycled" are selected.  I implemented some code in the "Save" function but it does not work.  I am very new to APEX so any help is greatly appreciated.  My code is as follows:

 

***************************************************CONTROLLER******************************************************

public class NewController {    

          public List<Account> myAccounts;        

              public Boolean isEditEnabled;        

 

public NewController(){        

      myAccounts = new List<Account>();                

                IsEditEnabled = false;    

}

 

public List<Account> getMyAccounts(){        

         myAccounts = [select Id,name,type, dq_reason__c,preferred_mode_s__c,micro_industry__c from Account WHERE (owner.id =: userinfo.getuserid())];                   

         return myAccounts;              

}           

public PageReference edit() {                

          isEditEnabled = true;                              

          return null;       

}    

public PageReference save() {                              

         for (account a: myaccounts){                

            if(a.type == 'Disqualified' || a.type == 'Recycled'){                    

                If(a.dq_reason__c == 'NULL'){                        

                  apexpages.addmessage(new apexpages.message(ApexPages.severity.ERROR,'Please enter a DQ reason'));                        

}                    

}                    

}                

          update myAccounts;                

          isEditEnabled = false;        

return null;       

}

public Boolean getIsEditEnabled(){                

        return isEditEnabled;        

}

}

 

 

*******************************************VISUALFORCE PAGE***********************************************

 

<apex:page controller="NewController" >
    
      <apex:form id="theForm">
    
        <apex:pageBlock title="My Accounts">
      
          
                <apex:pageblocktable value="{!myaccounts}" var="acct">
                    <apex:column headervalue="Account">
                         <apex:outputField value="{!acct.Name}" />
                         <apex:inputField value="{! acct.Name}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                   
                    <apex:column headervalue="Preferred Mode">
                         <apex:outputfield value="{!acct.Preferred_Mode_s__c}"/>
                         <apex:inputfield value="{!acct.Preferred_Mode_s__c}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                     
                    <apex:column headervalue="Type">
                         <apex:outputField value="{!acct.type}" />
                         <apex:inputField value="{! acct.type}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                   
                    <apex:column headervalue="DQ Reason">
                         <apex:outputField value="{!acct.DQ_Reason__c}" />
                         <apex:inputField value="{! acct.dq_reason__c}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                 
                </apex:pageblocktable>
                <apex:commandButton value="Save" action="{!save}" rerender="theForm"/>
            <apex:commandbutton value="Edit" action="{!edit}" rerender="theForm"/>
        </apex:pageblock>
  </apex:form>
</apex:page>

Hello,

 

I am still very new to APEX.  I am trying to develop a simple visualforce page that lists all the accounts the active user owns.  Ideally, the user should be able to edit and save the records.  When the user clicks save, the record in the database should update.  Currently, the edit and save buttons do not work but I can make changes when double clicking but they do not save.  Any help is greatly appreciated.

 

My code so far:

 

*********************Visualforce page************************

 

<apex:page controller="MyController" >
     
      <apex:form >
     
        <apex:pageBlock title="My Accounts">
       
           
                <apex:pageblocktable value="{!myaccounts}" var="acct">
                    <apex:column value="{! acct.name}"/>
                    <apex:column value="{! acct.Preferred_Mode_S__c}"/>
                    <apex:column value="{! acct.type}"/>
                     <apex:inlineEditSupport event="ondblclick"/>
                  
                </apex:pageblocktable>
                <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandbutton value="Edit" action="{!edit}"/>
        </apex:pageblock>
  </apex:form>
</apex:page>

 

 

*****************************Controller*****************************

 

public class MyController {

         public List<Account> getMyAccounts(){        

List<Account> a = new List<Account>();        

a = [select Id,name,type,preferred_mode_s__c,macro_industry__c,micro_industry__c from Account WHERE (owner.id =: userinfo.getuserid())];            

return a;           

}   

 

public PageReference edit() {        

return null;    

}

    public PageReference save() {        

return null;    

}

}        

I am using javascript remoting.  I have a situation where I need remote actions to execute in order.

The problem I am running into is the second remote action executes prior to the first one finishing.  Seems like I've tried everything!  Since remote actions are asynchronous, is it possible to execute them in order?  What is the best way to do so?


    Visualforce.remoting.Manager.invokeAction(
      '{!$RemoteAction.ChoptankRates.method1}',
      document.getElementById('var1').value,
                   
      function(result, event) {
        document.getElementById('var1').value = result[0].somevalue;
       
        //Execute second remote action now.
      }
    );
    Visualforce.remoting.Manager.invokeAction(
      '{!$RemoteAction.ChoptankRates.method2}',
      document.getElementById('VAR1').value,

      function(result, event) {
        //do something here
      }
    );
I am attempting to sort a list based on user clicking columns on visualforce page. Seems like the comparable interface is the best way to do this.

I can sort using static variables but it's messy. I would like to have dynamic variable to compare the list elements; however, I am receiving an error.  Any help is greatly appreciated.

public class loadsort implements Comparable  
    {  
      public parseUtility.load load {get; set;}   
        
      public loadsort(parseutility.load ld)  
      {  
        load = ld;  
      }  
        
      public Integer compareTo(Object VLoad)  
      {  
        loadsort LoadToComp = (loadsort)VLoad;  
        
        if(Load.get(comparefield) > Loadtocomp.load.get(comparefield))  
          return SortOrder.equals('asc') ? 1 : 0;  
        else
          return sortOrder.equals('asc') ? 0 : 1;
      }
    } 

This is the error:::::: Method does not exist or incorrect signature: [ParseUtility.load].get(String)
Dear all,
             i am writing a class to display contacts of standard objects(Contact). but while writing i got above problem. so could you pls rectify the problem? suggest me how to write program? what is the need of inner class? is it compulsory to write in every class.
this is my VF Page:
<apex:page standardController="Contact">
    <apex:form >
        <apex:pageBlock title="All Contacts">
            <apex:pageBlockSection >
                <apex:dataTable value="{!contact}" var="con" border="2" cellpadding="10">
                    <apex:column headerValue="Contact Name">
                        <apex:outputField value="{!con.lastname}"/></apex:column>
                    <apex:column headerValue="Account Name">
                        <apex:outputField value="{!con.name}"/></apex:column>
                    <apex:column headerValue="Lead Source">
                        <apex:outputField value="{!con.LeadSource}"/></apex:column>
                    <apex:column headerValue="Phone">
                        <apex:outputField value="{!con.Phone}"/></apex:column>
                    <apex:column headerValue="Fax">
                        <apex:outputField value="{!con.Fax}"/></apex:column>
                    </apex:dataTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
this is my controller:
public class Contact
{
    List<Contact> conlist = new List<Contact>();
    public List<Contact> displayContacts(){
        for(Contact c:[SELECT lastname,name,leadsource,phone,fax FROM Contact]){
            conlist.add(c);
        }
        return conlist;
    }
    
    public class contactwrapper
    {
        private Contact con{get;set;}
        public contactwrapper(Contact c){
            con = c;
        }
    }
}


 
Hi all,

I am trying to center a Google map on a location that is entered by the user.  A web service passes the city and state and retrieves the coordinates of said location and returns them to the controller.  I have a 'Get Map' button that calls a javascript function which should display and center the map using the coordinates from the controller.  The map is centered in the Indian Ocean. . . .

Now when I call the properties using outputtext tags in visualforce, they hold the value of the coordinates; however, when I call the properties in a JS function, they are null.  I have very little experience with JS.  Thanks in advance.

When debugging the JS, I get an error: *Uncaught ReferenceError: myLatlng is not defined.

----------------------------------------------------------------------------------------
Here is the function that my 'Get Map' button invokes:

<script>      
        function initialize() {
        var lat = '{!lng}';   // SHOULD HOLD CORRECT LNG BUT IS NULL
        var lng = '{!lat}';   // SHOULD HOLD CORRECT LAT BUT IS NULL
        var myLatlng = new google.maps.LatLng(lat,lng);
        var mapOptions = ({
        zoom: 10,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
   
    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
}
</script>

<apex:form id="frm">
   
    <apex:pageblock id="pblck">
    <apex:pageblocksection id="pbsectn" >
    <apex:inputtext value="{!city}" label="City" required="True"/>
    <apex:selectlist value="{!states}" multiselect="false" size="1" label="State" required="True">
        <apex:selectoptions value="{!items}"/>
    </apex:selectlist>
    </apex:pageblocksection>
    <apex:pageblockbuttons >
        <apex:commandButton action="{!submitRequest}" value="Sumbit Request" rerender=""/>
        <apex:commandbutton onclick="initialize()" value="Get Map" rerender="map-canvas"/>
    </apex:pageblockbuttons>
   
   
    <apex:pageblocksection id="results">
    <apex:outputtext value="{!lat}" id="lat"/>
    <apex:outputtext value="{!lng}" id="lng"/>   //CORRECT LAT AND LNG
    </apex:pageblocksection>
   
</apex:pageblock>
   
    <div id="map-canvas" style="width:100%;height:300px"></div>   // DOES NOT CENTER WITH CORRECT LAT AND LNG
    </apex:form>


------------------------------------------------------------------------------------------------
This is my controller for the visualforce page:

public decimal lat{get;set;}
public decimal lng{get;set;}

public decimal getlat(){
        return lat;
    }
   
    public void setlat(decimal lat) {
        this.lat = lat;
    }
    public decimal getlng() {
           return lng;
        }
         
    public void setlng(decimal lng) {
        this.lng = lng;
    }

public pagereference submitRequest(){
        googlenearbystorages gns = new googlenearbystorages(type, city, states, zipcode);
        lat = decimal.valueof(gns.latitude);
        lng = decimal.valueof(gns.longitude);       
    return null;
    }

Hello all,

I am learning apex, and have written several triggers. I thought I had figured out how to write a good test class, but unfortunately I did not. Can anyone tell me what I'm doing wrong?

 

My Trigger:

1
2
3
4
5
6
7
8 trigger scUpdate on Service_Call__c(before insert, before update){
    gii__SystemPolicy__c gii = [Select Mileage_Rate__c, Travel_Rate_Base__c, Travel_Rate__c from gii__SystemPolicy__c limit 1];
    for(Service_Call__c  sc : trigger.new){
        sc.Mileage_Rate__c = gii.Mileage_Rate__c;
        sc.Travel_Base__c = gii.Travel_Rate_Base__c;
        sc.Travel_Rate__c = gii.Travel_Rate__c;
    }
}

 

My Test Class: (not working)

1
2
3
4
5
6
7 @isTest 
private class TestscUpdate {
    static testMethod void insertNewCall() {
      Service_Call__c call = new Service_Call__c();
      insert call;
   }
}

 

The error: 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, scUpdate: execution of BeforeInsert

caused by: System.QueryException: List has no rows for assignment to SObject

Trigger.scUpdate: line 2, column 1: []

Hello apex experts,

 

I have a field on the account object that updates when the account is edited.  When the record is edited individually, the correct value gets written to the field.  When I use the data loader . . . One value applies to all records.  Here is my trigger, please advise.

 

trigger Populate_Transfer_Manager on Account (before insert, before Update) {   
   
    list<id> aid = new list<id>();
    for(account a: trigger.new){           
        aid.add(a.ownerid);
    }
    
list<user> managers = new list<user>();
    managers = [select managerid from user where id in: aid];
   

set<id> manid = new set<id>();                             
    for(user u: managers){
        manid.add(u.managerid);
    }
   

for(account a: trigger.new){        
    for(id i: manid){           
            a.transfer_manager__c = i;       
        }
    }
}

Hi all,

 

i have an apex class ,

global class TwilioWeeklyScheduleSMS Implements Schedulable
{
    global void execute( SchedulableContext sc )
    {
        ScheduledSMS();
    }
    public void ScheduledSMS()
    {
        String message = 'SMS messages were sent to the following accounts:\n';
        
        List<Account> acc = [SELECT Id, Name, Mobile__c from Account where Weekly_Scheduled_SMS__c = true];
    
        if ( acc.isEmpty() ) return;
       
        Set<String> sendToPhones = new Set<String>();
    
        for ( Account a: acc )
        {
            sendToPhones.add( a.Mobile__c );
            message += a.Name + '\n';
        }    
        TwilioMessageHelper.sendSMSMessage( sendToPhones, 'Test SMS' );


        List<SMS_History__c> list_SMS_Histories = new List<SMS_History__c>();   
        for ( Account a: acc )
        {
            list_SMS_Histories.add
            (   new SMS_History__c
                (   Account__c          = a.Id,
                    Message__c          = 'Test SMS ',
                    Mobile_Number__c    = a.Mobile__c
                )
            );
        }
        insert list_SMS_Histories;
        Messaging.SingleEmailMessage emailMsg = new Messaging.SingleEmailMessage();
        emailMsg.setToAddresses( new List<String>{'rajesh.dulhani@nanostuffs.com' } );
        emailMsg.setSenderDisplayName( 'TwilioSchedule_Weekly_SMS' );
        emailMsg.setSubject( 'SMS Messages Sent' );
        emailMsg.setPlainTextBody( message );
        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { emailMsg } );
    }
}

 

 

 

i have written the following test code ,

@istest(seeAllData=false)
public class TestTwilioWeeklyScheduledSMS {
    private static testmethod void TestTwilioWeeklyScheduledSMS (){
    
        List<Account> acc = [SELECT Id, Name, Mobile__c from Account where Weekly_Scheduled_SMS__c = true];
        if ( acc.isEmpty() ) return;
       
        TwilioWeeklyScheduleSMS sms  = new TwilioWeeklyScheduleSMS ();
        sms.ScheduledSMS();
        
    }
}

 

i run this test it passed but still the code coverage is 0 % . What should i modify in this test class . please help

 

Thanks

Hello,

 

I'm having issues with a trigger that I wrote to prevent users from saving cases with adding the Account Name and Contract ID.  Users can't submit record with a blank Account Name and Contract ID but they are able to submit records with blank Account Name and have a Contract ID.

 

Here's my code:

 

trigger PopulateSPIDContractIdonCase on Case (before insert, before update) {

    Profile p = [SELECT Id from Profile where Name='System Administrator'];
        
        if(System.Trigger.IsUpdate||System.Trigger.IsInsert)
        {
            for (Case c : trigger.new)
            
                if (UserInfo.getProfileId() != p.Id && (c.Reason__c == 'Recon Related') && (c.Account == NULL) && (c.Contract_ID__c == NULL))
                {
                c.addError('  Please enter a Contract ID and Account Name.');
                }
        }
       
}

 

Hello,

 

I am attempting to change the color of names in a list based on whether the ID in the field "Team__c" on the carrier object matches any ID in the list of users. My controller is returning the color one time and this color applies to all records (See debug log). All values in the list are blue, some should be red. Any help is greatly appreciated, thank you in advance.

 

 

Visualforce:::

 

<apex:pageblocktable value="{!carriers}" var="c">

    <apex:column headervalue="Carrier">

        <font color="{!color2}">

            <apex:outputtext value="{!c.name}"/>

        </font>

    </apex:column>

 

 

 

Controller:::

 

public string getcolor2() {

    list<carrier__c> carriers = [select team__c from carrier__c where team__c != NULL];

 

    list<user> users= new list<user>();

        users = [select id from user where userrole.name = 'Executive'];

            set<string> uid = new set<string>();

            for(user us: users){

                uid.add(us.id);

            }

 

    string color = 'red';

 

    for(carrier__c car: carriers){

        system.debug('*****List of carriers: ' + carriers);

        system.debug('*****List of users: ' + uid);

        system.debug('*****Current carrier= '+car);

        if(uid.contains(car.team__c) ){

            color='blue';

            system.debug('***** Set color to:'+color);  

            }

    }

    system.debug('***** Returning color: ' + color);

    return color;

}

 

 

Debug Log::::

 *****List of carriers: (Carrier__c:{Team__c=005U0000001D3E5IAK,      Id=a0HJ0000003bl8nMAA}, Carrier__c:{Team__c=005J0000001EEIHIA4, Id=a0HJ0000003bitnMAA}, Carrier__c:{Team__c=005U0000001BHRKIA4, Id=a0HJ0000003eD64MAE})

 

 *****List of users: {005U0000001D3E5IAK}

 *****Current carrier= Carrier__c:{Team__c=005U0000001D3E5IAK, Id=a0HJ0000003bl8nMAA}

 ***** Set color to:blue

 

*****List of users: {005U0000001D3E5IAK}

*****Current carrier= Carrier__c:{Team__c=005J0000001EEIHIA4, Id=a0HJ0000003bitnMAA}

 

*****List of users: {005U0000001D3E5IAK}

*****Current carrier= Carrier__c:{Team__c=005U0000001BHRKIA4, Id=a0HJ0000003eD64MAE}

 

***** Returning color: blue

HI,

 

         Generally how can we increase the test class code coverage, Is there any procedure to increase the test class code coverage...???

I've just written my first custom controller.  It's very basic and returns data from a custom object and sorts it by a date field.

 

The data is returned and then displayed on my visualforce page.

 

public List<News__c> newsList {get; set;}

public ctr_News() { }

// Get news method to return data
public List<News__c> GetNews(){ // Creates new list of News
// Below creates a new String based on the SOQL query, ordered by sort date
String strSql = 'SELECT Id, Name, Preview_Text__c, NewsBody__c, CreatedDate, Sort_Date__c FROM News__c ORDER BY Sort_Date__c ASC';
return database.query(StrSql); // Returns the SOQL string
} // End of method

} // End of class

 

 How would I go about putting a test class into this to verify the data returned is not null?

Hi ,

   I configured outbound message for a custom object. I have written webservice in .net WCF. In salesforce, Outbound delivery status throws an error , The message with Action  cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. When I checked with SOAP UI, It works fine. I am clueless, what is missing and why I get this error. Help please

 

  • September 12, 2013
  • Like
  • 0