• Vinoth Vijaya Basker
  • SMARTIE
  • 683 Points
  • Member since 2015

  • Chatter
    Feed
  • 22
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 83
    Replies
Hey guys, I've got a very simple trigger:
 
trigger TF on Account (before update, before insert) {
    for (Account a: trigger.New) {
        a.TestField__c = 'test';
    }

}

I wrote a test class for it:
 
@isTest
public class TFTest {
    @isTest static void testName() {
       Account cat = new Account();
        cat.Name = 'cat';
        insert cat;
        System.assertEquals('test', cat.TestField__c);
       }

}
When I run the test, I get an error:
 
Error Message	System.AssertException: Assertion Failed: Expected: test, Actual: null
Stack Trace	Class.TFTest.testName: line 7, column 1

I have two questions:
1) What am I doing wrong?
2) How come my trigger does not need to be tested and works already? I added an Account record already and the field gets populated.

Have a nice day


 
Hi,

I'm trying to create a truly bespoke Org for a project and would like to customise the look of my homepage.

When I click the pencil icon on the navigation bar, I can shuffle all the apps/items but there is no option to remove them.

I'm trying to reduce the clutter in my nav bar.

Is there anyway to do this?

Thanks!
I am getting an error while i am creating custom controller visualforce page  with account fields. getting error " Mycustom Compile Error: Method does not exist or incorrect signature: [System.PageReference].get(String) at line 5 column 184" 
my programme is

public class Mycustom {
public Account acc;
public Mycustom()
{
acc=[select id,name,phone,industry,website,rating,billingcity,description,fax,shippingcity,annualrevenue,billingcountry,shippingcountry from account where id=:apexpages.currentpage().get('id')];
}
public account getaccount()
{
return acc;
}
public pagereference savemethod()
{
update acc;
pagereference pageref=new apexpages.standardcontroller(acc).view();
return pageref;
}
}


and my controller page is

<apex:page controller="Mycustom" tabstyle="Account">
<apex:form >
<apex:pageblock title="account detail">
<apex:pageblocksection> title="account details1">
<apex:inputfield value="{account.Name}"/>
<apex:inputfield value="{account.phone}"/>
<apex:inputfield value="{account.industry}"/>
<apex:inputfield value="{account.rating}"/>
<apex:inputfield value="{account.website}"/>
</apex:pageblocksection>
<apex:pageblockSection title="account deatail2">
<apex:inputfield value="{account.billingcity}"/>
<apex:inputfield value="{account.billingcountry}"/>
<apex:inputfield value="{account.description}"/>
<apex:inputfield value="{account.fax}"/>
<apex:inputfield value="{account.shippingcity}"/>
<apex:inputfield value="{account.shippingcountry}"/>
<apex:inputfield value="{account.annualrevenue}"/>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Hi Everyone,

i have scenario . can you suggest me how to write trigger.
scenario is i have a standard object case. i have created a custom field which is of type checkbox.
i have created a record. on the record detail page we can post some comments using @mention xyz user.

when some one is posted comments using @mention username(owner of the record), i want to make that checkbox true.
what is relationship between case and casefeed.
can some one tel me how to write trigger for this.

Thanks
Lakshman

Hello,

im fairy new to triggers and im having some issues creating a trigger that will make a field mandatory. I tried to do this with a basic Validation rule however i beleive this exceeds salesforce point and click capabilities.

Case:
Im trying to create a validation rule where a user would be required to fill out the "Distributor_Name__c" name on the quotes object if "silver" is slected from the "Proofpoint_Advantage_Program_Level__c" field on the accounts object.

"Distributor_Name__c"  is a lookup field that looks up accounts and "Proofpoint_Advantage_Program_Level__c"  is a picklist.

i have tried creating a cross object validation rule however on the quotes object account fields do not show up. Is this possible? if not would this be done via trigger? This is what i attempted however iv had little success. Any help would be appreciated.

trigger Requiredistyfield on Quotes (Before insert,before update) {
    for (account quoteloop: Trigger.New){
        if (quoteinloop.Proofpoint_Advantage_Program_Level__c== 'silver'l)
            accountinloop.Distributor_Name__c!=NULL;
            }
        }


 
Hello

We have a custom object Individual Email Sends and I'm trying to write a trigger that updates a text field (Emails__c) on the related Account (lookup field).
So every time a new Individual Email is sent, it would then add the name of this email to the Email__c field, without deleting the previous data in it.

I know I'll need to create a List of all the Individual Email Sends, with after insert and after update.
Then a List of related Accounts that need to be updated, but how do I find the related Accounts for it?

Thanks!
Hello,

Why is it that the same report contents show different number of records to different users ?

thanks for suggestions !
  • December 16, 2015
  • Like
  • 0
How to write a formula for adding one day if the selected date is sunday

Thanks in advance.
Hello,

I specified the date as "Next 3 weeks" but it shows me all the results with that date, Where am i going wrong ?

 
  • December 14, 2015
  • Like
  • 0
Hi,

I have taken the formula field to pull contact name from other custom object..........but it's showing the error Field Name does not exist. Check spelling.

contact is parent
custom object is Child

Lookup field is Practitioner_Name__c

I have given like dis: Practitioner_Name__r.Name


But error is coming.....Pls help me out.


Adv Thnx
Siv
  • December 14, 2015
  • Like
  • 0
Hello,

I have a validation rule.

I want it only for certain profiles, 

How can i do it ?
  • October 19, 2015
  • Like
  • 0
Hi All,
I am new to Salesforce. Just started learning. I have few basic questions as below. It would be great to learn things from you.

1) How to write a validation rule on Opportunity object to make sure that Description is not empty. If the description is empty it should throw an error.
2) Created one formula field called "Auto Complete" of type checkbox. How to make this field to true  when the opportunity stage = 'Closed Won'.
3) Created one custom field called "Is Closed" of type checkbox. How to create a workflow rule to make this field to true when the opportunity stage = 'Closed Won'.
4) There are two custom fields - "DOB" and "Age", how to populate the "Age" value automatically when the DOB is selected?

Thank you!
  • October 10, 2015
  • Like
  • 0
Hi all,

I need to check the record type we selected when we create the case. As an example please check below screenshot. 
i need to capture which record type user has created (i need to capture that in Triger.Insert
User-added image

Thanks alot
I am trying to build a Validation Rule that if our opportunity stage is Closed Won, Closed Lost, No Decision, that the custom resolution feilds we created for resolution need to be filled out. I read some old forms and I was told to use a formula like this, but it does not seem to be working. Is there something I am doing wrong?
Thanks in advance

AND ( 
TEXT(StageName) = "Closed Won,Closed Lost,No Decision", 
ISBLANK( Resolution_Date__c ))
User-added image
This is the code firing multiple times when the oppty stage is changed to closed won. At the same time the oppty is marked closed one, I have potentially two WFRs firing. One WFR checks a date field. If that date field is blank, then it auto populates it with a calculated date. The second WFR fires if the date field changes and just copies that date adding one day to it.

Those two WFRs firing makes the trigger fire 2 more times. What can be changed int eh trigger to make it only fire once when the oppty is changed to closed won the first time. Seems there needs tob e an ISCHANGED clause but I do not know how to add that.
I am trying to figure out how Queue works, so I created a new queue in Leads but now I can't figure out how exact can a record be manually added to the queue list. Any help is appreciated thank you! :)
  • September 20, 2015
  • Like
  • 1
Currently I need your expert help to solve one requirement. Hopefully you will help me.
 
Requirement
One VF page which will show a list of User(Manage User) data. And  user will able to update Active field from that list. Means user can uncheck Active field and save so that User will be inactive in database.
 
My Implementation
I have created a custom controller to fetch specific set of user data. Please find below apex code


public class ReportController{
                 public List<User> reportRecord{
                 get{
                            return [SELECT Name,Username,Country_Code_AZ__c,LastLoginDate,Datediffcalc__c,IsActive  FROM User WHERE Datediffcalc__c > 90 and IsActive=true order by Country_Code_AZ__c];   
                 }
                set;
                   }   
      public PageReference QuickSave(){
               return null;   
                 }
}
 Also created a VF page where Active field is editable, please find below page code
 
<apex:page controller="ReportController">
<apex:form >
    <apex:pageBlock title="Users List">
    <apex:commandButton value="Inactive User" action="{!Quicksave}"/>
   
        <apex:pageBlockTable value="{!reportRecord}" var="val">
            <apex:column headerValue="Name" value="{!val.Name}"/>
            <apex:column headerValue="Username" value="{!val.Username}"/>
            <apex:column headerValue="Country Code" value="{!val.Country_Code_AZ__c}"/>
            <apex:column headerValue="LastLoginDate" value="{!val.LastLoginDate}"/>
            <apex:column headerValue="Days Since Last Login" value="{!val.Datediffcalc__c}"/>
            <apex:column headerValue="Active">
                <apex:inputField value="{!val.IsActive }"/>
            </apex:column>
 
        </apex:pageBlockTable>
  </apex:pageBlock>
 
  <apex:commandButton value="Inactive User" action="{Quicksave}"/>
  </apex:form>
</apex:page>
 
 
Problem Statement
Actually I am unable to write edit code under PageReference QuickSave() so that when user unchecked that flag and click on save , the updated value will be saved.
 
Please help me on the above situation or if you have any doc or video which implement same, please forward to me.
Hi ALL , 
 If a user logging with salerep profile , in Opportunity , stage picklist he should be unable to select a value called Needs Analysis.

please correct my rule :
AND 
( $Profile.Name = "Sales Profile" && 

Not( 
ISPICKVAL(StageName, "Needs Analysis") 

)
 
I have several apex class tests that are failing because we switched our state and country address fields to picklists.  I tried to correct it in the code but am still getting the same error:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, There's a problem with this country, even though it may appear correct. Please select a country from the list of valid countries.: [BillingCountry] 
Stack Trace: Class.Z_PaymentMethodCaptureControllerTest.createTestAccount: line 276, column 1 Class.Z_PaymentMethodCaptureControllerTest.testAppendMessages: line 185, column 1

When creating the account as part of the test, I code it to input United States, a value in our picklist field for BillingCountry.  

Tried to research answers but am coming up dry.  Any help out there?
Hi All, 

For time based workflow actions, we can monitor using Monitoring window of Time based workflow actions. Through Scheduled Date column, we can know when(Date/Time) action will be executed. 

For Scheduled Actions of Process, I would like to know the Scheduled Date of scheduled actions. 

In Flows, I could only see the Paused Date. Please help me to find the way to know Scheduled date of Scheduled actions of Process.

Thanks,
Vinoth
i want to find out test code coverage apex class so that i ask my devloper to increase the code coverage, how do i find , pls suggest
I am trying to convert date in yyyy-mm-dd format but I am getting result in yyyy-dd-mm format.

Initial Value of DateField: 
datetimeinquiry=2019-06-11 00:00:00

Tried newInstance
    convertToStr = DateTime.newInstance(datetimeinquiry.year(),datetimeinquiry.month(),datetimeinquiry.day()+1).format('yyyy-MM-dd'); 
Result:2019-06-11

Tried formatGMT:
    system.debug('formatGMT: '+datetimeinquiry.formatGMT('yyyy-MM-dd'));
Result:2019-06-11
Hey guys, I've got a very simple trigger:
 
trigger TF on Account (before update, before insert) {
    for (Account a: trigger.New) {
        a.TestField__c = 'test';
    }

}

I wrote a test class for it:
 
@isTest
public class TFTest {
    @isTest static void testName() {
       Account cat = new Account();
        cat.Name = 'cat';
        insert cat;
        System.assertEquals('test', cat.TestField__c);
       }

}
When I run the test, I get an error:
 
Error Message	System.AssertException: Assertion Failed: Expected: test, Actual: null
Stack Trace	Class.TFTest.testName: line 7, column 1

I have two questions:
1) What am I doing wrong?
2) How come my trigger does not need to be tested and works already? I added an Account record already and the field gets populated.

Have a nice day


 
Hi,

I'm trying to create a truly bespoke Org for a project and would like to customise the look of my homepage.

When I click the pencil icon on the navigation bar, I can shuffle all the apps/items but there is no option to remove them.

I'm trying to reduce the clutter in my nav bar.

Is there anyway to do this?

Thanks!
Hi All,

I'm really struggling to find out how to add a welcome message on the homepage / sidebar in Lightning. 

Previously I could do this in SF Classic:
Setup > Customize > Home > Homepage Components > Edit Messages and Alerts 

I'm using the Trailhead sandbox environment for a work project. 

Any support would be massively appreciated. 
I am getting an error while i am creating custom controller visualforce page  with account fields. getting error " Mycustom Compile Error: Method does not exist or incorrect signature: [System.PageReference].get(String) at line 5 column 184" 
my programme is

public class Mycustom {
public Account acc;
public Mycustom()
{
acc=[select id,name,phone,industry,website,rating,billingcity,description,fax,shippingcity,annualrevenue,billingcountry,shippingcountry from account where id=:apexpages.currentpage().get('id')];
}
public account getaccount()
{
return acc;
}
public pagereference savemethod()
{
update acc;
pagereference pageref=new apexpages.standardcontroller(acc).view();
return pageref;
}
}


and my controller page is

<apex:page controller="Mycustom" tabstyle="Account">
<apex:form >
<apex:pageblock title="account detail">
<apex:pageblocksection> title="account details1">
<apex:inputfield value="{account.Name}"/>
<apex:inputfield value="{account.phone}"/>
<apex:inputfield value="{account.industry}"/>
<apex:inputfield value="{account.rating}"/>
<apex:inputfield value="{account.website}"/>
</apex:pageblocksection>
<apex:pageblockSection title="account deatail2">
<apex:inputfield value="{account.billingcity}"/>
<apex:inputfield value="{account.billingcountry}"/>
<apex:inputfield value="{account.description}"/>
<apex:inputfield value="{account.fax}"/>
<apex:inputfield value="{account.shippingcity}"/>
<apex:inputfield value="{account.shippingcountry}"/>
<apex:inputfield value="{account.annualrevenue}"/>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Hi Everyone,

i have scenario . can you suggest me how to write trigger.
scenario is i have a standard object case. i have created a custom field which is of type checkbox.
i have created a record. on the record detail page we can post some comments using @mention xyz user.

when some one is posted comments using @mention username(owner of the record), i want to make that checkbox true.
what is relationship between case and casefeed.
can some one tel me how to write trigger for this.

Thanks
Lakshman
Hello,

I have a Picklist with 10 values already exsisting.

I want to add new 4 values which should only be available for specifu record type on the same object.
  • December 18, 2015
  • Like
  • 0
I have created same fields for Customer and oppertunity object.When i create a new record for customer that fields values should update in Oppertunity also.For this i have written a trigger between these two objectwith the event after insert, But i am getting error.
Please correct the below code if it is wrong.
trigger updateField on Contact (after insert) {
 Set<Id> Ids= new Set<Id>();
    for (Contact contact : Trigger.new)
    {
    Ids.add(customer.Id);   
    }
  List<Contact> contactList = new List<Contact>([Select Id,SMETS_Meter_version__c,Meter_Status__c  FromContact where Id in :Ids]);    
       for(Contact temp : contactList )
       {
       Oppertunities oppor = new  Oppertunities();
       oppor.SMETS_Meter_version__c = temp.SMETS_Meter_version__c;
       oppor.Meter_Status__c = temp.Meter_Status__c;
       insert oppor;
       }
     }
example
 name: {!.v.name}
address:{v.address}
phone:{v.phone}

output:

name:        bob
address​​​​​:    California
Phone:      ​852-895-7854

Please tell me your suggestions​
HI,

What happen we have mentioned @istest(seeall=false ).

Regards,
viswa.