• Anupama Samantroy
  • NEWBIE
  • 469 Points
  • Member since 2015
  • Senior Developer
  • CloudinIT


  • Chatter
    Feed
  • 14
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 133
    Replies
Hi Everyone,
I need to use a condition , when ever  an Opportunity is created with its stage as 'Won' and recordtype name as 'Global' a record in custom Object has to be created ,i am good till here , what I wonder is , Is there any way that i can use Opportunity Object's record type name without querying RecordType Object, all i am looking for is a condition like below to be built without querying another Object coz i already have a list Opp,

If (Opp.StageName='Confirmed' && RecordTypeName(would like to use this as a string )= 'Global') 

Thanks
Ck


 
For the community self registration page if the user enters the detail, I want to check if the contact already exist on the basis of email entered by user. If it does, I want to create user for that existing contact. How can achieve this?
hi

our visualforce page for customer voucher requires to have a small change where it used to display the voucher value how much is gifted, we want it to now show how many hot laps gifted instead of $ amount

original code showing voucher value using merge field Voucher_Value__c with Formula (Currency) field type on object voucher:
<tr>
<td class="tdbordernobottom" width="300" align="right" bgcolor="#ffe383"><strong>No of V8 Laps:&nbsp;</strong></td>
<td class="tdbordernoleft">&nbsp;<apex:outputField value="{!voucher.Voucher_Value__c}"/></td>
</tr>

i made changes by replacing with merge field No_of_V8_Laps__c with Formula (Number) field type on object voucher:
<tr>
<td class="tdbordernobottom" width="300" align="right" bgcolor="#ffe383"><strong>No of V8 Laps:&nbsp;</strong></td>
<td class="tdbordernoleft">&nbsp;<apex:outputField value="{!voucher.No_of_V8_Laps__c}"/></td>
</tr>

it doesnt work however, just showing blank or the page doesnt even load properly

can anyone help and tell me what im doing wrong please?

thanks 
In an opportunity, I have the following picklist values for opportunity stage:
"Unqualified"
"Qualified - Undefined Scope"
"Qualified - Defined Scope"

There is a field titled " Fee Estimate", which is currently set to not required.
If the values of only "Qualified - Undefined Scope" and "Qualified - Defined Scope" are selected, how can there be a validation rule that requires a user to fill out the field "Fee Estimate".

ie. the field "Fee Estimate" has to be filled in everytime the opportunity stage is either Qualified - Undefined Scope"
"Qualified - Defined Scope". It is not required for "Unqualified".

Can someone please help in guiding me where to start?

Thank you in advance!
Hello,

I want to remove role of a certain user because of business need.
The user at present has role "Administration", i want  to change it to blank , i have done this steps for others users, which run with no problem but for one particular user it is creating issue, it is giving error like below

User-added image

How can i resove the issue ?
  • July 20, 2016
  • Like
  • 0
Class code for particular Method:
 public pagereference SearchManifests(){
        string sProjName = MAdminRecTemp.Project_Name__c;
        string sProjIteration = MAdminRecTemp.Project_Iteration__c;
        string sStory_Issue = MAdminRecTemp.Story_Issue__c;        
        string soql = 'select id, name,Project_Name__c,Project_Iteration__c,Story_Issue__c,Comments__c,CreatedDate  from Manifest_Administration__c';
        string sSearchSpecAdditional = ' where RecordTypeId !=\''+sRecTypeId+'\''; // get only Dev To QA Manifests
        
        if(string.isNotEmpty(sProjName)){
            sSearchSpecAdditional += ' AND Project_Name__c = \''+sProjName+'\'';
        }
        if(string.isNotEmpty(sProjIteration)){
            sSearchSpecAdditional += ' AND Project_Iteration__c = \''+sProjIteration+'\'';
        }        
        if(string.isNotEmpty(sStory_Issue)){
            sSearchSpecAdditional += ' AND Story_Issue__c = \''+sStory_Issue+'\'';
        }
        soql = soql + sSearchSpecAdditional;
        
        MAdminSearchResults = new list<Manifest_Administration__c>();
        MAdminSearchResults = database.Query(soql);
        wrapMAdminSearchResultList = new list<wrapManifestAdminRecord>();
        for(Manifest_Administration__c ma : MAdminSearchResults){
            wrapMAdminSearchResultList.add(new wrapManifestAdminRecord(ma));
        }        
        bAddbtnDisable = (wrapMAdminSearchResultList !=null && wrapMAdminSearchResultList.size()>0 ? false : true);
        ClearSearchFields();
        return null;
    }

My Test class:

@isTest
public class INTC_ManifestAdminNew_CXTest
{
    public static testMethod void Test_INTC_ManifestAdminNew_CX()
     {
      
      String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Manifest_Administration__c' LIMIT 1].Id;
      
      Test.StartTest();
     //create new Manifest Administration Record
     Manifest_Administration__c ma=new Manifest_Administration__c(Project_Name__c = 'Customer First - Release 1',Project_Iteration__c = 'Sprint 2',
                                                                  Story_Issue__c = 'Prod Migration',
                                                                  Comments__c = 'Test',RecordTypeId=strRecordTypeId);
     insert ma;
     
       List<Manifest_Item__c> MI=new List<Manifest_Item__c>();
       Manifest_Item__c mit=new Manifest_Item__c();
       mit.Manifest_Name__c=ma.id;
       mit.Metadata_Item_Name__c='CRM Developer';
       mit.Metadata_Type__c='Profile';
       
       insert mit;

     ApexPages.StandardController controller = new ApexPages.StandardController(ma);
     INTC_ManifestAdminNew_CX MANC=new INTC_ManifestAdminNew_CX (controller);
     system.assert(MANC != null); 
     INTC_ManifestAdminNew_CX.wrapManifestAdminRecord Wrapvar = new INTC_ManifestAdminNew_CX.wrapManifestAdminRecord (ma); 
           
     MANC.SearchManifests();
     MANC.ClearSearchFields();
         
     MANC.AddRecords();
     MANC.RemoveSelectedSearchRecords();
     MANC.BuildPackage();
     MANC.RemoveSelectedAddedRecords();
     Test.stopTest();
     }
}

If i comment the method for Search Manifests it is covering 33%


Please anyone help me to cover this method 
I'm new programming and need some help...
I want to make a trigger to prevent deleting Accounts that have any Location associated. If an account has an associated Location, I want to display an error message.
There are a lookup field on Accounts to Location (Location__c).
Can you help me?
Thanks!
I've got a trigger which calls a method in a class designed so that the Hiring Manager (lookup field on Position) automatically follows their Positions in Chatter:
 
Class:
public class SubscriptionsClass { 
public static void HiringManagerSubscribeNewPosition(List <Position__c> positions) {
System.Debug('HiringManagerSubscribeNewPosition: Entering');
List <EntitySubscription> subscriptions = new List <EntitySubscription>();
for (Position__c pos :positions) {
EntitySubscription eSubs = new EntitySubscription(parentid = pos.id, subscriberid = pos.Hiring_Manager__c);
subscriptions.add(eSubs);
Database.insert(subscriptions);
}
}
 
Trigger:
trigger PositionTrigger on Position__c (after insert) {
SubscriptionsClass.HiringManagerSubscribeNewPosition(Trigger.new);
}
 
Works great but I can't figure out how to account for the possibility that a Hiring Manager for a Position could change; any ideas? Thanks for any help and advice.
I'm trying to complete the "Getting Started with Apex Unit Tests" module on the trailhead. I got to the challenge and created the test class. I did as it says and did an "All Run" then went to complete the challenge, but I got an error back. I checked to see what tests were run and the class I created doesn't show up. I go to "New Run" and it doesn't show up. I saved the class then closed and reopened the tab only to find this:
public class TestVerifyDate{

}

I retyped my code, saved it (ctrl +c and File > save), copied it, and repeat the steps above. Same thing. When I open the code it comes up blank. Luckily I copied it so I can paste it back in. I closed and reopened the DC window. The tab remembers what I typed, but if I close and reopen it gets wiped. I have logged out and back in; all to no avail. So long story short, what is going on? Why won't my class save anything other than the basic starting info? 

Here's a sample of the code. All of the tests repeat the same format so I won't copy them for the sake of brevity.
 
@isTest
private class TestVerifyDate {

    @isTest static void dateTest11(){
        Date date11 = VerifyDate.CheckDates(07/18/2016, 07/29/2016);
        System.assertEquals(07/29/2016, date11);
    }

//Repeat other tests below. All brackets are closed, all semi-colons are present.
//This follows the TemeratureConverterTest example test class format shown in the module,
//Only changes are variables, methods, etc.

}


 
Good evening. I'm seeing an odd behavior with the code. It appears my if conditions are being ignored for if blocks that involve VariableA, VariableB an VariableC if the system reports back as null. It seams to treat NULL as a string. The code is designed to scale the where clause based on if a value is not null. If the value is null, i want it to be excluded from the conditions.add commands which therefore would prevent it from being written into StrQuery. If the value is not null, I want it to be included in the conditions.add commands. 

Here's an example: 

If VariableA,B &C contains data the conditions list would report back 3 + 1 for recordid being automatically added

If VariableA,B contans data, the conditions list would report back 2 + 1 for recordid being automatically added

If VariableA contains data (B,C are null) then the list would report back 1 + 1 for recordid being automatically added. 

Ideally I'm looking for the code to work for any combination of A,B,C (eg. B,C, C,A etc.). This makes up 3 conditions to the third power or nine combinations. 

My code is below: 

String strQuery = 'select id from objectname__c '; 
String VariableA;
String VariableB;
String VariableC;
 
List<string> conditions = new List<string>();
   String Esc = '\'';
   conditions.add('RecordID =' + Esc  +RecordID+ Esc +' ');
   system.debug('the filtered value of RecordID is:' + RecordID);

    //adds VariableA when VariableA not null
    if(VariableA != null) {
        conditions.add('FieldA__c  ='+ '' + Esc + VariableA + Esc); 
        system.debug('Added Value from Field A: ' + conditions);
        } 
    //adds VariableB when VariableB not null 
    
    if (VariableB != null) { 
        conditions.add('FieldB__c =' + '' + Esc +VariableB  + Esc); 
        system.debug('Added Value from Field B: ' + conditions);
    } 
    //adds VariableC when VariableC is not nuull
    if (VariableC != null) {
        conditions.add('FieldC__c=' + Esc +VariableC + Esc);
        system.debug('Added Value from Field C: '+ '' + conditions + Esc); 
        } 
    system.debug('Conditions Size is:' +conditions.size()); /number of conditions added

    //////// determines what to add to SOQL query statement
    
    if (conditions.size() > 0) {
        strQuery += 'WHERE ' + conditions[0];
        
        for (Integer i = 1; i < conditions.size(); i++)
            strQuery += 'AND ' + conditions[i];
        }
        
   system.debug('the list of conditions' + conditions);    
   system.debug('the final query' + strQuery);

I have this scenario:
abc_c,(A)+ def_c,(West)  + ghi_c,(Elite) = xyz_c, (90,000)
abc_c,(B)+ def_c,(MidWest) + ghi_c,(Preferred) = xyz_c, (50,000)


Values in the () are values from a picklist. The custom api fields are picklists which contains various values. Whenever any of these combinations are selected, the final value should be the set value, e.g., 90,000.


What would be the correct syntax to write this up, thanks in advance!

Hi, 

I have some functionality that reads a group of records from a related list for display in a pageblock table based on a criteria i have set in the SOQL query. I have some values in a field lets call the field filterA that could be duplicate of other items. I'd like to read the full list of records for my query and dedup any entries. 

I've tried set but as the record ids are unique, I'll end up with the same number of records being read. Any ideas on how I can screen out the duplicates? 

Here's a visual example: 

Filter A (values)
A
A
A
A
A
A
B
B
C

My end result would be to get a list with A,B,C vs. displaying all values as I plan to pass A,B,C, to a selectlist and selectoption. I'm interested in this because This field Filter A would then be used in another piece of functionality to effectively filter based on a action from a command button and a SOQL query that would engage Filter A. I prefer to build this list based on the data vs. hardcoding. 
Hi, please help on writing test class for below controller:
public class DataTableExampleController {
    public List<Contact> contactList{
        get{
            if(contactList ==Null){
                contactList = [select Account.Name, FirstName, LastName, Phone from Contact limit 10000];
            }
            return contactList;
        }
        set;
            }
        }
     Test class:
@isTest
public class Test_DataTableExampleController {
    static testMethod void testSave(){
           Test.setCurrentPage(Page.DataTablePage);
        Account acc = new Account(Name = 'Test');
        insert acc;
        Contact con = new Contact(LastName = 'Test', AccountId = acc.Id );
        insert con;
        
        DataTableExampleController dt = new DataTableExampleController ();
 //   dt.contactList = 'test';
   //     System.assertEquals(contactList, 'test');
    }
}
Thank You.
I want to send the email to the community guest user about the new case creation. I have created a Auto Response Rules and checking if the Web Email is not null then using the template for the Guest Users. But it does not send the email.
Though sending emails to the Contact works fine. Is there any way we can send the response emails to the unauthenticated users using Case Auto Reponse Rule?
Hi,

In one my site pages some has used the site label user_information. But when i checked the salesforce list of site labels I did not fine this one neither there is custom label of this name. Similalry below custom labels are being used in the page but I can't find the documentation for the same.
{!$Label.site.user_information}
{!$Label.site.address_information}
{!$Label.site.contact_information}

Any help is appreciated.

Thanks
Anupama
I have a requirement that on creation of Contact an User should be created and on successful creation of user another Custom Object is to be created.
For the first part I have created a future method to create the user but as I cannot call another future method or batch class from that method I am not able to create the custom object.
Any help is appreciated.

Thanks 
Anupama
I have 2 approval process on Order object which has a user queue as the approver. I am not able to deploy the approval process using ant.
The error is that the QUEUE does not exists. I have manually created the queue but still the same issue.
https://success.salesforce.com/issues_view?id=a1p30000000T1p5AAC Salesforce says it has been fixed but I am still facing the same issue.

Any help is appreciated.

Thanks
Anu
Hi Everyone,
I need to use a condition , when ever  an Opportunity is created with its stage as 'Won' and recordtype name as 'Global' a record in custom Object has to be created ,i am good till here , what I wonder is , Is there any way that i can use Opportunity Object's record type name without querying RecordType Object, all i am looking for is a condition like below to be built without querying another Object coz i already have a list Opp,

If (Opp.StageName='Confirmed' && RecordTypeName(would like to use this as a string )= 'Global') 

Thanks
Ck


 
For the community self registration page if the user enters the detail, I want to check if the contact already exist on the basis of email entered by user. If it does, I want to create user for that existing contact. How can achieve this?
Hello,

I am neew to Apex coding and am struggling with the tresting.  I created a class to filter accounts by record type that returns the results correctly.  I have written a test class, but I am receiving an error message  that reads "Constructor not defined: [ApexPages.StandardSetController].()".  I am not able to figure out or find the solution to fix this error.  Below is the code from the test class:

@isTest
public class TestFilterAccountSummary {
 static testMethod void myAccountFilterTest() {

    Account acc = new Account(Name='Test Account');
    insert acc;
   
     Test.StartTest();
      ApexPages.StandardSetController sOC = new ApexPages.StandardSetController();
        sOC.setSelected(new List<Account>{acc});
        FilterAccountSummary fAS = new FilterAccountSummary(sOC);

     Test.StopTest();
   
    }
}

The error is in line 9 which I have ubderlined in the code above.

I have also posted the code for the Apex class that I am testing below: (This code is working as expected, but thought it may be helpful)

public class FilterAccountSummary {
    public ApexPages.StandardSetController Acc {
        get {
            if (Acc == null){
                Acc = new
                    ApexPages.StandardSetController(Database.getQueryLocator(
                        [Select
                        Id,
                        Name,
                        RecordType.Name,
                        Industry
                        From Account
                        Where RecordType.Name In ('Standard BDAP')]));
            }
            return Acc;
        }
        set;
    }
    public List <Account> getAccounts(){
        Return (List<Account>) Acc.getRecords();
    }

}

Thank you in advance for your help,
Jim
Hi All,

I want to get the the product name(in Product2 object), product group name (in Product_Hierarchy__c) from price book entry on below criteria, I have written this query which is wrong I believe. Can anyone please help me out in querying. Providing relationship btween objects from schema builder.
User-added image

Select Product2.Name,
Product_Hierarchy__c.Name
From PricebookEntry, Product2, Product_Hierarchy__c
Where PricebookEntry.Pricebook2Id = ’ 01s30000000GUqhAAG’ and
PricebookEntry.Product2Id = Product2.Id and Product2.Product_Hierarchy__c = Product_Hierarchy__c.Id

Please advice.
I am try below code and its not showing email display name, even its not showing full email address. Its just picking before the @ symbol like if my org wide address is asw_india_supp@gmail.com then in from it will come asw_india_supp

Here is my code peice 
Messaging.SingleEmailMessage singEmail = new Messaging.SingleEmailMessage ();
	String [] toAddresses = new list<string> {'ashwani.pradhan@test.com'};
	
	//Set recipient list
	DateTime d = DateTime.now() ;
	String dateStr =  d.format('MMM-dd-yyyy');
	// Use Organization Wide Address  
	for(OrgWideEmailAddress owa : [select Id, Address, DisplayName from OrgWideEmailAddress]) {
		if(owa.Address.contains('ir')) singEmail.setOrgWideEmailAddressId(owa.id); 
	}  

	singEmail.setToAddresses (toAddresses);
	singEmail.setSubject('Salesforce Contact Correspondence Details Report as of '+ dateStr);
	
	singEmail.setHtmlBody('Hello');

	Messaging.SendEmailResult [] r = Messaging.sendEmail (new Messaging.SingleEmailMessage [] {singEmail});
Please help..
 
hi

our visualforce page for customer voucher requires to have a small change where it used to display the voucher value how much is gifted, we want it to now show how many hot laps gifted instead of $ amount

original code showing voucher value using merge field Voucher_Value__c with Formula (Currency) field type on object voucher:
<tr>
<td class="tdbordernobottom" width="300" align="right" bgcolor="#ffe383"><strong>No of V8 Laps:&nbsp;</strong></td>
<td class="tdbordernoleft">&nbsp;<apex:outputField value="{!voucher.Voucher_Value__c}"/></td>
</tr>

i made changes by replacing with merge field No_of_V8_Laps__c with Formula (Number) field type on object voucher:
<tr>
<td class="tdbordernobottom" width="300" align="right" bgcolor="#ffe383"><strong>No of V8 Laps:&nbsp;</strong></td>
<td class="tdbordernoleft">&nbsp;<apex:outputField value="{!voucher.No_of_V8_Laps__c}"/></td>
</tr>

it doesnt work however, just showing blank or the page doesnt even load properly

can anyone help and tell me what im doing wrong please?

thanks 
Hi,

In one my site pages some has used the site label user_information. But when i checked the salesforce list of site labels I did not fine this one neither there is custom label of this name. Similalry below custom labels are being used in the page but I can't find the documentation for the same.
{!$Label.site.user_information}
{!$Label.site.address_information}
{!$Label.site.contact_information}

Any help is appreciated.

Thanks
Anupama
In an opportunity, I have the following picklist values for opportunity stage:
"Unqualified"
"Qualified - Undefined Scope"
"Qualified - Defined Scope"

There is a field titled " Fee Estimate", which is currently set to not required.
If the values of only "Qualified - Undefined Scope" and "Qualified - Defined Scope" are selected, how can there be a validation rule that requires a user to fill out the field "Fee Estimate".

ie. the field "Fee Estimate" has to be filled in everytime the opportunity stage is either Qualified - Undefined Scope"
"Qualified - Defined Scope". It is not required for "Unqualified".

Can someone please help in guiding me where to start?

Thank you in advance!
Hello All, 

I have a requirement where I need to present a Master detail objects in the form of a question(master) and radio button options (detail)

Example:

1. What is the Capital of USA
  • Washington DC
  • Newyork
2. What is the Capital of India
  • New Delhi
  • Mumbai
  • Hyderabad
  • Bangalore
  • Chennai
3. What color is a Rose
  • Red
  • Pink
  • Yellow

Here the Master record is the Question and the Child options are the detail records. 

User-added image

I have achieved half of it, but I am finding difficulty associating the detail records to their respective masters on the VF page

User-added image

Here is the code 
 
<apex:page standardController="EFL_Inspection_Questionnaire__c" extensions="CARPOL_inspection_questionnaire" showHeader="true" >
  <h1>This is how the Questionnaire is going to look</h1>
  <apex:form >
  <apex:repeat value="{!qs}" var="q" id="theRepeat">
        <apex:outputText value="{!q.Question__c}" id="question"/><br/>
        <apex:selectRadio value="{!country}">
            <apex:selectOptions value="{!items}"/>
        </apex:selectRadio>
        <apex:inputField value="{!q.Comments__c}" style="width: 400px; height: 40px" id="comments"/><br/><br/><br/>
    </apex:repeat>
    
    

</apex:form>
</apex:page>



**********************************************controller*************************************

public class CARPOL_inspection_questionnaire {
    String country = null;
    List<EFL_Inspection_Questionnaire_Questions__c> questionnairequestions = new List<EFL_Inspection_Questionnaire_Questions__c>();
    Id questionnaireid;
    public CARPOL_inspection_questionnaire(ApexPages.StandardController controller) {
    questionnaireid = ApexPages.currentPage().getParameters().get('id');
    }
    
    public List<EFL_Inspection_Questionnaire_Questions__c> getqs() {
       questionnairequestions= [SELECT ID,NAME,Question__c,Comments__c,Answer__c FROM EFL_Inspection_Questionnaire_Questions__c WHERE EFL_Inspection_Questionnaire__c=:questionnaireid];
        return questionnairequestions;
    }
    
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        
        List< EFL_Inspection_Questionnaire_Responses__c > responseoptions = new List< EFL_Inspection_Questionnaire_Responses__c >();
        responseoptions = [SELECT ID,NAme, EFL_Inspection_Questionnaire_Questions__c, Response__c FROM EFL_Inspection_Questionnaire_Responses__c WHERE EFL_Inspection_Questionnaire_Questions__c IN:questionnairequestions];
        
        for(EFL_Inspection_Questionnaire_Responses__c r:responseoptions){
            options.add(new SelectOption(r.Response__c,r.Response__c));
        }
        return options;
    }
    
    public String getCountry() {
        return country;
    }
                     
    public void setCountry(String country) { 
        this.country = country; 
    }
}




I would be grateful if anyone could help me out with this. 


Thanks a lot
Nitish

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.