• GhanshyamChoudhari
  • SMARTIE
  • 961 Points
  • Member since 2018

  • Chatter
    Feed
  • 30
    Best Answers
  • 0
    Likes Received
  • 4
    Likes Given
  • 0
    Questions
  • 212
    Replies
Hi.
I have 2 questions. It is possible to have a field in read only until some other field is fill with certain value? And related, it is possible hide or not hide a field with that logic?

Thanks in advance
Hi there

I have a custom field on my Account object, say 'refered_by__c'. This field contains the ID of another Account object.

I want to write a SOQL something like this (psedu query):

    select id, name, refered_by__c, <name of "refered_by__c"> from account 

Please advise how can I write this query using SOQL.

Thank you!
Hello, I am working through the Visual Force Basics module and in Use Standard Controllers I am up to this part:

For example, while viewing the object details for Account, you might have noticed that the Account object has a field called Account Owner...

WHERE would I be viewing the object details for Account? Adding a link to that text referencing the page it is referring to would definitely be helpful. And a possibly related question is, are there any API docs that just have all of the objects, methods, and fields listed as a reference?

Thank you
Hi All,

I am new to Salesforce and need some urgent help to write logic for search filter on VF Controller.

I have two filer field i.e. Name and Email id on lookup VF page which display the list of users and it is being controlled by a controller.

Request you please suggest me a logic in such a way like if a user tries to search with Name, Email id or both. Then the list should populate result accordingly.

I want to put this in the 'Where' condition to fetch the result using string Soql.

Select name,emailid from User where name like '%XYZ%'  and EMaild like '%XYZ%';

Kindly suggest.
Lookup Filter on VF page


Regards,
Vinay
As much as I appreciate this forum I have some questions on the way it works:

1. Why can't we paste screenshots
2. Why cant we enlarge screenshots in posts
3. Why can't we edit our own post
4. Why are we forced to mark another's post as 'Solved' when it was not the post but something else we might have found on our own
5. Being mostly a developer forum, why is there no way to mark a block of code as such; instead of having it in an unreadable non-monospace font blending with rest of message
6. Why is there no spell-check; seems like the browser's default text-area spell check has been disabled ?
7. Why I always get a 503 message after every post.
 
I have a Lightning Component which displays a <table> element after rendering.
I want to access the table and add a class to it, but for some reason it does not find the table.
Please help.
 
<aura:handler name="render" value="{!this}" action="{!c.onRender}"/>
onRender: function (component, event, helper) {
        var table = document.getElementsByTagName("table");
        if (table != undefined) {
            table.classList.add("slds-p-bottom_large");
        }
    }
getElementsByTagName does not find the table, why?

 
Hello,

I am using visualforce page and using slds to get the tab view. but the tab label comes in Caps and I can not change the font and size of tab label.

I am using exactly the same code present in SLDS tab page(https://www.lightningdesignsystem.com/components/tabs/#site-main-content)

User-added image

I want to reduce the size, change the font and wanted to view it like Item One.

Please help me on this.

Thanks
Preyanka

 
Hello,

i have created lighting quickaction. Can anyone tell me how i can change the title/header of the appearing modal? I need to have it different from the label i have specified for the button.

thanks
Peter
not able to migrate my javascript button in lightning experience. please help me to convert the below button. I am new to Lightning. current onclick javascript action: window.location.href ='/apex/RequestType?&id={!Opportunity.Id}';
Here is the Apex and VF code for the reference:-

//Apex Code
 
public class sendEmailbuttonApex
{
    public Account accounts                     {set;get;}
    public String subject 				{set;get;}
    public String body 			        {set;get;}
    public blob Attach                                {set;get;}  

    public sendEmailbuttonApex(Apexpages.StandardController controller)
    {
        accounts=(Account)controller.getRecord();
        accounts=new Account(Name='Test');
    }
    public PageReference sendEmail()
    {
        List<Contact> conList=[Select Id, Email from contact where Email='abhishekk.twopirconsulting@gmail.com'];
        system.debug(conList);
        List<String> mail=new List<String>();
        for(Contact c:conList)
        {
            mail.add(c.Email);
        }
        Messaging.SingleEmailMessage msg1=new Messaging.SingleEmailMessage();
        msg1.setToAddresses(mail);
        msg1.setSubject(subject);
        msg1.setPlainTextBody(body);
        Messaging.Email[] emails=new Messaging.Email[]{msg1};
        Messaging.sendEmail(emails);
        insert accounts;
        Blob b = Attach;
        Attachment At = new Attachment(Name ='NewFile',body = b,ParentId=accounts.Id);
        insert At; 
        
        PageReference p=new PageReference('https://mail.google.com/mail/u/0/#inbox');
        p.setRedirect(true);
        return p;
        
    }
}

//VF code
 
<apex:page docType="HTML-5.0" standardController="Account" extensions="sendEmailbuttonApex">
    <head lang="en">
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
        </head>
        <body>
           <apex:form >
                <script src="https://code.jquery.com/jquery-1.8.3.min.js"></script>
     		<br /><br />
        <apex:outputLabel value="Subject" for="Subject"/>:<br />     
        <apex:inputText value="{!subject}" id="Subject" maxlength="80"/>
        <br /><br />
        <apex:outputLabel value="Body" for="word_count"/>:<br />     
        <apex:inputTextarea id="word_count" cols="30" rows="10" value="{!body}" />
        <br />
        Total word Count : <span id="display_count">0</span> words. Words left : <span id="word_left">40</span>
         <br /><br /><br />
        <apex:commandButton value="Send Email" action="{!sendEmail}" /> 
        <apex:inputFile value="{!Attach}"></apex:inputFile>
           </apex:form>
    	<script>
 			$(document).ready(function() {
			//   alert('Hello, jQuery');
            $('[id$=word_count]').on('keyup', function(e) {
                //  alert('hey');
                //j$('[id$=word_count]').on('keydown', function(e) {
                var words = $.trim(this.value).length ? this.value.match(/\S+/g).length : 0;
                if (words <= 40) {
                   $('[id$=display_count]').text(words);
                   $('[id$=word_left]').text(40-words)
                }else{
                    if (e.which !== 8) e.preventDefault();
                }
            });
        }); 
        </script>
    </body>
</apex:page>

​ 
We have a custom object called FMS Work Orders. Our users must have the "modfy all" permission, but I do NOT want them to delete Work Order records. I have followed this example to set up a trigger which stops the deletion of a record. The problem is the test class runs, cannot delete the record, which is the desired behaviour, but treats the test as a fail. Can anyone help pont out what's wrong with the test class?

Trigger:
trigger PreventWODeletion on FMS_Work_order__c (before delete) {
    for(FMS_Work_order__c FWO : TRIGGER.OLD){FWO.ADDERROR('Work Order cannot be deleted');}
}

Test Class
@isTest 
private class testPreventWODeletion
{
    
static testmethod void PreventWODeletion1() { 
    
 FMS_Work_order__c FWORecord = new FMS_Work_order__c(); 
 FWORecord.Issue_Description__c='Test123';
 FWORecord.Case_number__c='5006E000004jB49QAE';
 insert FWORecord; 

 try{ 
 delete FWORecord;
 }
    
 catch(DMLException e){ 
 system.assert(e.getMessage().contains('Work Order Cannot be deleted'),'Work Order Cannot be deleted'); 
 } 
    
 } 
}


 
Hello,

In the community page layout, I created a custom component on the product page layout. What I need to do now is when clicking on this custom component (a button), I want to send an email to the admin and to update the record of the product. Is this possible? Thank you.

 
Hi all,

I have a requirement in visualforce Email template. I need to conditionally display subject for Email templates based on a field value. I found the below one in some blog.
<messaging:emailTemplate subject="{!IF(relatedTo.LeadSource = 'Web','This is PG1 subject', IF(relatedTo.LeadSource = 'Other','This is PG2 subject','false') )}"  recipientType="Lead" relatedToType="Lead">
 
<messaging:plainTextEmailBody>
 
{!
IF(relatedTo.LeadSource = "Web","This is PG1 email"
,
IF(relatedTo.LeadSource = "Other","This is PG2 email ","false")
)
}
 
</messaging:plainTextEmailBody>
 
</messaging:emailTemplate>
But in the subject i want to display Leasd source as well. Subject would be like "This is PG1 Email Web"/"This is PG1 Email Other".
Please help me with this requirement.

Thanks.
I am struggling on the first unit. When I enter the details for Fumiko Suzuki and then hit Save and New, I get an error message saying it is a duplicate username. I have changed the username several times to account for this, but each time it comes up with the same message. I’ve set up a new trailhead playground and the same thing is happening. Any ideas will be appreciated!

User-added image
To handle asian and some european (e.g. Hungarian) names  with less confusion I'd like to rename/relabel "First Name" and "Last Name" to "Given Name" and "Family Name" respectively.

Is this possible?
Hello All,
Can someone plese help me writting a trigger so that whenever I save a task record it must insist me to add an attachment on task.

Thanks and regards,
Dj367

 


My apex class\\
public with sharing class accountobj {
    @AuraEnabled
    public static list<account> getAccountss(){
        list<account> accountss=[select id,name,phone,billingcity from account limit 100];
        return accountss;
    }


}


My component is 
<aura:component controller="accountobj">
    <aura:attribute name="accountss" type="account[]"/>
    <ui:button label="Get accounts" press="{!c.getac}"/>
     <aura:iteration var="account" items="{!v.accountss}">
        <p>{!account.name}:{!account.phone}</p>
    </aura:iteration>
    
</aura:component>

my controller js

({
    getac:function(rec) {
        var action=rec.get("c.getAccountss");
        action.setcallback(this,function(response){
      
        var state = response.getState();
        if(state === "SUCCESS"){
            rec.set("v.accountss",response.getReturnValue());
        }
                           });
    $A.enqueueAction(action);    
    }
})
 
Example :

Probability (%) =15%
Then due date should be = due date+15%

My Trigger :
trigger createTask on Opportunity (after insert, after update) {
List<Task> Tasks = new List<Task>();
  if(Trigger.isInsert && Trigger.isAfter){
  for(Opportunity o: Trigger.New){
    Task ts=new Task(subject='stage1',ActivityDate= o.CloseDate-120, WhatId= o.id);
    tasks.add(ts); 
    Task ts1=new Task(subject='stage2',ActivityDate= o.CloseDate-90, WhatId= o.id); 
    tasks.add(ts1); 
    Task ts2=new Task(subject='stage3',ActivityDate= o.CloseDate-80, WhatId= o.id);
    tasks.add(ts2); 
    }
    insert Tasks;
    }
    
if(Trigger.isUpdate && Trigger.isAfter){
system.debug('********');        
for(Opportunity o: Trigger.New){
List<Task> latestRecords = [SELECT Id,Subject,WhatId,ownerId,Status FROM Task WHERE WhatId =: o.Id];
    
system.debug('Tasks:'+latestRecords);
  for(Task t: latestRecords){
  if(o.StageName == '2'){
  if(t.subject == 'stage1'){
  t.Status = 'Completed';
  }
  }
  if(o.StageName == '3'){
  if(t.subject == 'stage2'){
  t.Status = 'Completed';
  }
  }
  if(o.StageName == 'Closed Lost'){
  if(t.subject == 'stage3'){
  t.Status = 'Completed';
  }
  } 
  }
  update latestRecords;
  }
  }
}
  • April 30, 2018
  • Like
  • 0

As apex:pageblock is not supported in SLDS it's suggested to use slds-panel and slds-panel_section to replace page block and pageblocksection respectively. In my existing code I use rendered property of pageblock section extensively. Is it possible to apply same conditions to a div that replaces the pageblocksection? for example:
<apex:pageBlock title="Account & Opportunity Information" rendered="{!myCondition}">
Can this be replaced with
<div class="slds-panel slds-grid slds-grid--vertical slds-nowrap slds-form--compound" aria-labelledby="newaccountform"
rendered="{!myCondition}">

OR
 
<apex:pageBlockSection title="AccountInformation" collapsible="false" columns="2" rendered="{!myCondition == null}">
with
<div class="slds-panel__section"  rendered="{!myCondition == null}">



<div class="slds-panel__section"  rendered="{!myCondition == null}">
Hi.
I have 2 questions. It is possible to have a field in read only until some other field is fill with certain value? And related, it is possible hide or not hide a field with that logic?

Thanks in advance
Hi All,

I was reading through the apex guide and i came across the statement which actually i didnt understand.
Could you please explain me that.

"The @isTest annotation can take multiple modifiers within parentheses and separated by blanks."

What does is mean here .An example /scenario would actually help.

Thanks a lot in advance!

Deepshikha
How to find contacts which do not have cases, opportunities, activities, etc so that we can delete such contacts from the database? 
Thanks in advance.

Yogesh

 
I new to Apex, and failing miserably.  Time and time again and I cannot come up with anything beyond 0% code coverage.  I have the following trigger:
trigger leadDuplicatePreventer on opportunity(before insert) {
   set<string> settgs = new set<string>();
   list<opportunity> opps = [select id,Trigger_Help__c  from opportunity WHERE CreatedDate = LAST_N_DAYS:90];
   Profile p=[SELECT ID, Name FROM Profile WHERE Id=:userinfo.getProfileId() Limit 1];
   for(opportunity opp : opps){
     if(opp.Trigger_Help__c != null && p.Name <> 'System Administrator'){
	 settgs.add(opp.Trigger_Help__c);
	 }
   }
   
   for(opportunity op : trigger.new){
      if(settgs.contains(op.Trigger_Help__c)){
	     op.adderror('An Opportunity of this type already exists on this Account.  Please contact a system administrator with questions.');
	  }
   
   }


   
}

The Trigger_Help__c is a formula field that combines Oppty_Type__c+Account Id.  These 9 lines are all I have to figure out and I cannot get this for the life of me.  My current test class is as follows:

@isTest
private class TestleadDuplicatePreventer {
    @isTest static void TestleadDuplicatePreventerwithOneOpp() {
    Account acct = new Account(Name='Test Account');
    insert acct;
    Opportunity opp = new Opportunity(Name=acct.Name + ' Opportunity',
                                     StageName='Open Opportunity',
                                     CloseDate=System.today().addMonths(1),
                                     Facility__c='Tacoma WA',
                                     Oppty_Type__c='UCO Service',
                                     AccountID=acct.Id);
    insert opp;
    Test.startTest();
    opp= new Opportunity(Name='Opportunity Test',
                        StageName='Open Opportunity',
                        CloseDate=System.today().addMonths(2),
                        Facility__c='Tacoma WA',
                        Oppty_Type__c='UCO Service',
                        AccountId=acct.Id);
    try
    {
        insert opp;
    }
    catch(Exception duplicate)
    {       
       System.assertEquals('An Opportunity of this type already exists on this Account.  Please contact a system administrator with questions.', duplicate.getMessage());
    }
    //this should probably be in a separate test method
    Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
  User u2 = new User(Alias = 'newUser', Email='newuser@testorg.com',
     EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
     LocaleSidKey='en_US', ProfileId = p.Id,
     TimeZoneSidKey='America/Los_Angeles', UserName='newuser@testorg.com');

  System.runAs(u2) {
      insert opp;
  }
        Test.stopTest();}}
But I have also been trying and failing with the following test class:
 
@isTest
public class TestleadDuplicatePreventer {
    static testMethod Void TestleadDuplicatePreventerwithOneOpp() {
        User u1 = [SELECT Id FROM User WHERE Alias='jmilt'];
        System.runAs(u1){
        Account acct = new Account(Name='Test Account');
        insert acct;
        Opportunity opp1 = new Opportunity(Name=acct.Name + ' Opportunity',
                                         StageName='Open Opportunity',
                                         CloseDate=System.today().addMonths(1),
                                         Facility__c='Tacoma WA',
                                         Oppty_Type__c='UCO Service',
                                         AccountID=acct.Id);
        Opportunity opp2 = new Opportunity(Name=acct.Name + ' Opportunity1',
                                          StageName='Open Opportunity',
                                          CloseDate=System.today().addMonths(1),
                                          Facility__c='Tacoma WA',
                                          Oppty_Type__c='UCO Service & Indoor Equipment',
                                          AccountID=acct.Id);
        Opportunity opp3 =  new Opportunity(Name=acct.Name + ' Opportunity2',
                                           StageName='Open Opportunity',
                                           CloseDate=System.today().addMonths(1),
                                           Facility__c='Tacoma WA',
                                           Oppty_Type__c='Trap Service',
                                           AccountID=acct.Id);
            Opportunity[] opps = new Opportunity [] {opp1, opp2, opp3};
            insert opps;
            
        Opportunity dup1 = new Opportunity(Name='Check',
                                          StageName='Open Opportunity',
                                          CloseDate=System.today().addMonths(1),
                                          Facility__c='Tacoma WA',
                                          Oppty_Type__c='UCO Service',
                                          AccountID=acct.Id);
            Test.startTest();
        try
        {
            insert dup1;
        }
        catch(Exception duplicate)
        {    
            System.assertEquals('An Opportunity of this type already exists on this Account.  Please contact a system administrator with questions.', duplicate.getMessage());

        }}
   Test.stopTest(); }

}

If anyone is out there who can help it would be greatly appreciated!

I am trying to hide a contact tab from the nav bar for the end user.
surpisingly the contact tab is not included in nav bar but still its appearing on the nav bar(with *).
when I try to close the tab & relogin its appearing again.
Please let me know if I am missing any setting
Hi All,

I cam across a scenario while making my functionality in lightning a managed package. 

Before having a namespace, my functionality was wrking fine where I was able to receive the attributes from another component in the init method perfectly fine when the component was dynamically created. 

this attributes stopped coming in child when I create a namespace

Any clues ?
 
When creating a lighting action (with action type as Custom Visualforce or Lightning Component), there is no provision to specify the width (of the modal pop-up). While this can be achived by including custom CSS to the class 'slds-modal__container', I'm not sure if that's the right way to go. Im assuming here that Salesforce or Lightning platform first defines width of the modal pop-up and then resizes contents within according the to the outer HTML element width. If we apply custom CSS, then it will most possibly act on the Outer HTML but not on all of the inner content. is my assumption correct? If yes, then what is the right way to achieve modifying the modal pop-up width?
Hi,

I have a batch class running, which allocates sales rep based on the the zip code assigned.

My problem here is , It is running for one profile , but not running for other. .

Is there something in configuration , that I am missing ? Please advise 

 
I am logged into my DE account as system administrator and I am trying to import excel data into a custom object with data import wizard, but I get this prompt when I click on Custom Object.  This has never happened before, have I accidentally turned a permission off?  Where do I go to edit my permission for data import?  Thanks!


User-added image
I created a very basic Trigger:

trigger HelloWorld on Lead (before update) {
    for (Lead L : Trigger.new) {
    L.FirstName = 'Hello';
    L.LastName  = 'World';
  }
}

When I create a new Lead record in Classic, it works as expected (ie, no change since it should fire only in Update) but when I create a new Lead record in Lightning, as soon as I save, the first and last name gets updated to Hello World.

This is a brand new developer Org and so there are no other triggers etc. Has anyone else run into this problem?
I want to display all the cases with have attachments in a table along with the File name and other file related information in lighting component
 
We would like to copy the account billing address to a contract (not contact) record upon saving the contract record. We have a lookup relationship to the account (standard field within the comtract record). Can this be done via a formula field?
I created a very basic Trigger:

trigger HelloWorld on Lead (before update) {
    for (Lead L : Trigger.new) {
    L.FirstName = 'Hello';
    L.LastName  = 'World';
  }
}

When I create a new Lead record in Classic, it works as expected (ie, no change since it should fire only in Update) but when I create a new Lead record in Lightning, as soon as I save, the first and last name gets updated to Hello World.

This is a brand new developer Org and so there are no other triggers etc. Has anyone else run into this problem?
The salesforce if it involves too much coding ,then i noticed lot of complexities in the code whenever the salesforce updates some of its featues, i would like to know why would someone go for hardcore customization in salesforce instead of choosing  java and heroku? In this case ,their are quite a lot of advantages like
1: no limits as in salesforce
2: licenses are cheap so if the user count is high , it will profitable in the long run
3: No need to have dependency on the existing functionality which may mess with the functionality required.( i have personally been through this, where an existing functionality completely complicated the custom development required)
4: And also need not concern the code breaking because of any standard functionality changes in salesforce ( i have been through this when creating the dynamic thread id in salesforce ,it crashes at some time and no guarante will it work later)

Do share your thoughts to it.

Thanks and Regards,
Shiva RV
Hi All,

I am having 2 Lightning Component. 
Lightning Component - A  having Button.
If I am clicking on the button in Lightning Component - A. Lightning Component - B should refresh. 

Do you have any sample codes please post below.