• Prafull G.
  • SMARTIE
  • 1734 Points
  • Member since 2011
  • Technical Consultant


  • Chatter
    Feed
  • 55
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 358
    Replies
I need to write a soql query for  DLRS that will return records with a date in the year prior to "last fiscal year." Is there soql syntax that will return "2 fiscal years ago"? 

My current query is 
Select ID from School_Report_Card__c WHERE School_Year_of_This_Report_Card__c = Last_Fiscal_year

But I need the year before that. Is this possible?
I am trying to extract the data via data loader, I am looking for the following criteria.
First Name contains 0,1,2,3,4,5,6,7,8,9
How do I put this in the SQL query? 
Hello, I have a daily-scheduled-import of several new records, and names come in with inconsistent capitalization. I want my before insert trigger to make all the names appear normal (first letter of each name capital, the rest lower case.) I found code so far which does this but it leaves it as a list. How can this return a normal string of the name, with first then last name, in the normal format I want? 

String s;
     s = 'joHN JONSOn';
String [] lines = s.split('\n');
integer j = 0;
            for (String line:lines) {
String [] words = line.split(' ');
integer i = 0;
                for (String word:words) {
                    words[i] = word.trim().tolowercase().capitalize();
                    i++;
                }
                lines[j] = String.join(words,' ');
                j++;
                s = string.valueof(lines);
                system.debug(s);
            }


 
Hi,

I am trying to a button using Javascript which uses a variable determined by whether the user has selected either standard or premium support.
However, I keep getting "Unexpected token ;". Any help is appreciated. 

Here is the script I am using:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

var cost;

if ({!ISPICKVAL(Quote.S_W_Support_Level__c , 'Premium')}) { 
cost = {!Quote.S_W_Premium_Maintenance__c};
} else {
cost = {!Quote.S_W_Standard_Maintenance__c};
Hi,

I am having the following below javascript in a vf page which is displaying the users in a table


I have added a link to the user where on click of the link it should redirect me to the corresponding user record, i have added the link using <a href > tag, 

Need help on user record redirection

My Java script



<apex:page showheader="true" sidebar="true">
    <script type="text/javascript">
    var __sfdcSessionId = '{!GETSESSIONID()}';
    </script>
    <script src="../../soap/ajax/29.0/connection.js"
          type="text/javascript"></script>

<script>
function getUserInfo() 
  {    
  try
  {
  var userInfoById = {};   
  var output='<font size="2" color="blue"><table><tr><th>User&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Open Tasks&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Open Opportunity&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Open Threat</th></tr></font>';

  //logic to fetch the frozen users list
  var result = sforce.connection.query("Select Id,LastModifiedDate ,FirstName, LastName from User where Id in(Select userId  From UserLogin WHERE IsFrozen = TRUE) AND IsActive=true");      
  var it = new sforce.QueryResultIterator(result);  
  while(it.hasNext())  
  {     
  var record = it.next();
 
  //logic to fetch the open Task count 
  var taskcount = sforce.connection.query("Select id from Task where Status!='completed' AND ownerid='"+record.Id+"'");      
  var taskresultset =taskcount.getArray("records"); 
  var taskresultcount;
  if(taskresultset!=null)
  {
  taskresultcount=taskresultset.length;
 
  }
  else
  {
  taskresultcount ='';
  }
 
  //logic to fetch the open opportunity count
 
  var opportunitycount = sforce.connection.query("SELECT ID FROM Opportunity WHERE StageName != 'Closed Won' AND StageName != 'Closed Lost' AND ownerid='"+record.Id+"'");      
  var oppresultset =opportunitycount.getArray("records"); 
  var oppresultcount;
  if(oppresultset!=null)
  {
  oppresultcount=oppresultset.length;
 
  }
  else
  {
  oppresultcount='';
  }
 
 
  //logic to fetch the open Threat count 
  var threatcount = sforce.connection.query("Select id from Threat__c where Status__c !='Closed Won' AND Status__c !='Closed Lost'  AND ownerid='"+record.Id+"'");      
  var threatresultset =threatcount.getArray("records"); 
  var threatresultcount;
  if(threatresultset!=null)
  {
  threatresultcount=threatresultset.length;
 
  }
  else
  {
  threatresultcount='';
  }
 

  var name=record.FirstName + ' ' + record.LastName;
  var date = new Date(record.LastModifiedDate);
  console.log(date.toISOString().slice(0,10));
  output+='<tr><td><a href="#">'+name+'</a></td><td>'+date+'</td><td>'+taskresultcount+'</td><td>'+oppresultcount+'</td><td>'+threatresultcount+'</td><td>';
  output+='</td></tr>';
  output+='</td></tr>';

  }      
  output+='</table>';
  document.getElementById('output').innerHTML=output;
  }
  catch (e)
  {
     alert('Exception = ' + e);
  }  
  }
  </script>
 

<apex:sectionHeader title="Frozen State Users:"/>

  <div id="output"> </div>
  
  <script>
    getUserInfo();
  </script>
</apex:page>


Thanks in Advance


Hello,

I have a trigger on a custom object (Client_Revenue__c).  When a record is created, edited, or deleted for this object, the trigger links the record of the current year (based on a field called Revenue_Year__c in the custom object) to a custom lookup field on the Account.  The test I created is only covering 25% of the trigger.  Lines 12 - 25 and 32-42 are not being covered.  Does anyone know why this would be happening?  Thanks,

Trigger:
trigger Contract2Account on Contract_Summary__c (after insert, after update, after delete) 
{          
    Try
    {
     Map<Id,Account> oppMap = new Map<Id,Account>();
     Set<id> Ids = new Set<id>();

if(trigger.isInsert || trigger.isUpdate)
{
    if(checkRecursiveAI.runOnceAI() || checkRecursiveAU.runOnceAU())
    {
        for (Contract_Summary__c prgm : Trigger.new){
            if(prgm.Type_of_Contract__c == 'Renewal' || prgm.Type_of_Contract__c == 'Initial MSA')
            Ids.add(prgm.Account_Name__c);
        }
     
        Map<id,Account> acctMap2 = new Map<id,Account>([Select Id,Name,Contract_Summary__c, Contract_Summary__r.Current_Effective_Date__c from Account Where Id in :Ids]);  
        for (Contract_Summary__c  prgm2 : Trigger.new){
            if(acctMap2.containsKey(prgm2.Account_Name__c) && (acctMap2.get(prgm2.Account_Name__c).Contract_summary__r.Current_Effective_Date__c < prgm2.Current_Effective_Date__c || acctMap2.get(prgm2.Account_Name__c).Contract_summary__r.Current_Effective_Date__c == null)) {
                Account a = acctMap2.get(prgm2.Account_Name__c);
                a.Contract_Summary__c = prgm2.Id;
                oppMap.put(a.id,a);
            }
        }
        update oppMap.values();
    }
}
     
if(trigger.isDelete)
{
    if(checkRecursiveAD.runOnceAD()){
        for (Contract_Summary__c prgm : Trigger.old){
            if(prgm.Type_of_Contract__c == 'Renewal' || prgm.Type_of_Contract__c == 'Initial MSA')
            Ids.add(prgm.Account_Name__c);
        }
        Map<id,Account> acctMap2 = new Map<id,Account>([Select Id,Name,Contract_Summary__c from Account Where Id in :Ids]);  
        for (Contract_Summary__c  prgm2 : Trigger.old){
                Account a = acctMap2.get(prgm2.Account_Name__c);
                a.Contract_Summary__c = null;
                oppMap.put(a.id,a);
        }
        update oppMap.values();
    }
}
    }
    catch(Exception e)
    {}
}

Test Class:

@isTest(SeeallData=true)
private class ContractSummary_Tests2 {

    private static testmethod void testSummary1() {

    Account a1 = new Account();
        a1.name = 'test';
        a1.Type = 'Employer';
    insert a1;
   
    Opportunity opp1 = new Opportunity();
            opp1.Name = 'Test Opportunity';
            opp1.StageName = 'Stage 6 - Live';
            opp1.CloseDate = date.newinstance(2020,1,31);
            opp1.Type = 'New Business';
            opp1.accountId=a1.Id;
        insert opp1;

    Opportunity opp2 = new Opportunity();
            opp2.Name = 'Test Opportunity';
            opp2.StageName = 'Stage 6 - Live';
            opp2.CloseDate = date.newinstance(2022,1,31);
            opp2.Type = 'Renewal';
            opp2.accountId=a1.Id;
        insert opp2;

    Contract_Summary__c testContSumm1 = new Contract_Summary__c ();
        testContSumm1.Related_Opportunity__c = opp1.Id;
        testContSumm1.Account_Name__c = opp1.Account.id;
        testContSumm1.Current_Effective_Date__c = date.newinstance(2020,1,31);
        testContSumm1.Current_Expiration_Date__c = date.newinstance(2022,1,31);
        testContSumm1.Type_of_Contract__c = 'Initial MSA';
        testContSumm1.Client_Signature_Date__c = date.newinstance(2020,1,31);
    insert testContSumm1;

    Contract_Summary__c testContSumm2= new Contract_Summary__c ();
        testContSumm2.Related_Opportunity__c = opp2.Id;
        testContSumm2.Account_Name__c = opp2.Account.id;
        testContSumm2.Current_Effective_Date__c = date.newinstance(2022,1,31);
        testContSumm2.Current_Expiration_Date__c = date.newinstance(2024,1,31);
        testContSumm2.Type_of_Contract__c = 'Renewal';
        testContSumm2.Client_Signature_Date__c = date.newinstance(2022,1,31);
    insert testContSumm2;

        
    Test.startTest();
    update opp1;
    update opp2;
    update testContSumm1;
    update testContSumm2;
    delete testContSumm2;
    Test.stopTest();

    }
}

Class to prevent infinite loops:
public Class checkRecursiveAI{
    private static boolean run = true;
    public static boolean runOnceAI(){
    if(run){
     run=false;
     return true;
    }
    else{
        return run;
    }
    }
}



  • July 21, 2014
  • Like
  • 0
Hello,

I have a custom object (Contract_Summary__c) that has a Master-Detail with Opportunity.  I have created a test class to test a trigger and I'm trying to populate the Account Name field on my Contract_Summary__c from the Opportunity field.  Can anyone give me the syntax to do this?  My code from the test class is below and Line 4 is where I'm having trouble:

public static Contract_Summary__c createContSumm(Id oppId){ 
        Contract_Summary__c ContSumm = new Contract_Summary__c();
            ContSumm.Related_Opportunity__c = oppId;
            ContSumm.Account_Name__c = oppId.AcctId.id;
            ContSumm.Current_Effective_Date__c = date.newinstance(2025,1,31);
            ContSumm.Current_Expiration_Date__c = date.newinstance(2027,1,31);
            ContSumm.Type_of_Contract__c = 'Initial MSA';
            ContSumm.Client_Signature_Date__c = date.newinstance(2025,1,31);
        return ContSumm;


  • July 21, 2014
  • Like
  • 0
Hi

I have created one custom text(Text01__c) field.This field allows  characters [a-z][A-Z] and space bar only.Any formula or validation rule or workflow rule.It not allows numarics [0-9] and special character

Best Regards,
Ramesh

A custom object, Data with three custom fields, Baseline, Change, and Proj

 

I'm trying to write:   If (change = blank, proj = baseline , else proj  = baseline + (baseline * change)

 

Here's my code but it's not working and I could use some help correcting it:

public class ROI_Calc{
    public static Integer calculateROI (data__c.lifetime_orders_projected__c v) {
        if (lifetime_order_value_change_proj__c == '') {
            v = lifetime_order_value_baseline__c; }
           {v = lifetime_order_value_baseline__c * lifetime_order_value_change_proj__c + lifetime_order_value_baseline__c;
           } 
    }
}

 

Hello,

We have situation where people are changing Case Record Type from one to another. I know we can track this by turning on the history tracking. But we want a way to see it as a field on the Case.

 

So I need to capture the old value of Record type in Old Value field

 

Record Type. 1) Regular 2) Strategic

Text field: Old Value

 

Can anyone help me to write an trigger?

 

 

Thanks a lot!

 

Shruti

I have Vf page with two buttons, Accept and Decline, and fields like Name Account ID, mobile number,If Accept  button is clicked, i want the details from vf page to be added as a contact in AccountID mentioned.

Hi All,

 

In Campaign object, there are 4 custom fields where I need to check the uniqueness as a group before its commited to the database

 

Field 1 - Custom Picklist

Field 2-Custom Picklist

Field 3-Custom Picklist

Field 4-Custom Date

 

If the above 4 fields are unique then only it will allow to save the Campaign record.

 

Please help to how it can be achievable.

 

At the moment I have thought of creating a dummy field of type TEXT and making it as unique.

Using Workflow field update I will concatenate the above 4 fields and store the values in the dummy field.

If its unique then only it will allow to save otherwise throw error as its unique.

 

Is that the right approach? Please advise how do I concatenate the 4 fields in the formula editor.

  • July 26, 2013
  • Like
  • 0

Hi,

 

   Can you provide access to view report to only Specified User? Please let me know. 

 

Thanks
Sudhir

Hi all,

 

I have a small query that :

 

My senario is that I am using javascript remoting to pass data from page to controller and then fill a wrapper class(json parser).

but in javascript we can only use static variables so i made my wrapper object as public static. 

Every thing work and I get the Data in controller but when I tried to write it to VF page it give me "Unknown property 'fbIntegrationDataController.id'"

So how to get Data from it I also have getter setter for that but still not able to do so.

Public static fbIntegrationDataController fbClassObj{get;set;}

    public static void setfbClassObj(fbIntegrationDataController f){
        fbClassObj = f;
    }
    public static fbIntegrationDataController getfbClassObj (){
        return fbClassObj;
    }

@RemoteAction
    global static string getsetfbData(String tokenname) {
        fbData = tokenname; 
        fbClassObj = parse(fbData);
        return '';
}

public String name;
    public String email;
    public String id;
    public Picture picture;
    
    public class Picture {
        public Data data;
    }

    public class Data {
        public String url;
        public Integer width;
        public Integer height;
        public Boolean is_silhouette;
    }

    public static fbIntegrationDataController parse(String json) {
        return (fbIntegrationDataController) System.JSON.deserialize(json, fbIntegrationDataController.class);
    }

 

VF Page component class Not getting value of soID.query works if i pass hard coded ID.Please someone tell me where i am wrong..**The constructor gets called first, before any variables are set. I dont know how to do this...

 

 

public with sharing class saleslinecntlr {
public string soID{get;set;}
List<Sales_Order_Line__c> saOrderLin;
public saleslinecntlr ()
{
System.debug('---------'+soID);
    saOrderLin=[Select id,name,Product__r.Name,Serial_Number__c,Quantity__c,Sale_Price__c,Total__c
                                             from Sales_Order_Line__c where salesorderid=:**soID** order by name];


}
    public List<Sales_Order_Line__c> getsaOrderLin() {
    return saOrderLin;
}

}

 

Hi I am having a custom "convert" button on custom object. Once i click the convert button it will create a account and contact. Once again i click convert button i must tell that the record already exist in account and contact "Duplicate won't be allowed". This "convert" button is similar to our lead convert button. Kindly anyone tell how to resolve this.Kindly tell me code for this.

Here i have given my apex class code:

Code:

 

public class LeadConversion {

    public PageReference RedirecttoLead()
     {
        String currentLead = '/' + leadObj.Id;
        PageReference pageRef = new PageReference(currentLead);
        return pageRef;
     }

     private CustomLead__c leadObj;
    
    // The extension constructor initializes the private member
    // variable acct by using the getRecord method from the standard
    // controller.
    public LeadConversion(ApexPages.StandardController stdController)
     {
     System.debug('******Sai******');
             leadObj = (CustomLead__c)stdController.getRecord();
    }
    
    public void convertLead(){
    
        Account acc = new Account();
        acc.Name = leadObj.Name;
        acc.Companynamelead__c = leadObj.CompanyName__c;
      
       try 
       { 
        insert acc; 
       }
        Catch (Exception ex1)
        {
        
         ex1.getmessage();
        }
        Contact cc = new Contact();
        cc.Lastname = leadObj.Name;
        cc.Lastname_lead__c = leadObj.LastName_c__c;
        cc.AccountId=acc.Id;

      
       try 
       { 
        insert cc; 
       }
        Catch (Exception ex2)
        {
        
         ex2.getmessage();
        }
        
        Opportunity opp = new Opportunity();
        opp.Name = leadObj.Name;
        opp.AccountId=acc.Id;
        opp.opp_namelead__c = leadObj.opp_name__c;
        opp.OPP_DateOfBirth__c = '20.03.1976';
        opp.StageName = 'Qualification';
        opp.closedate = date.today()+3; 

       
        try 
         { 
         insert opp; 
        }
        Catch (Exception ex3)
        {
         
         ex3.getmessage();
        }
        
      
        
    }
    
    }

 

Can anyone tell how resolve this.

 

Thanks, Regards, lavanya.

Hi,

 Can any one help me out to write test class for below apex class.

 

public class StopRecursivecall
 {
                 private static boolean Update_OnBehalfendUserStatus = false;
      public static boolean hasUpdate_OnBehalfendUserStatus() 
                  {
        return Update_OnBehalfendUserStatus;
     }
                 public static void setUpdate_OnBehalfendUserStatus() {
        Update_OnBehalfendUserStatus = true;
    }
 }

 Thanks,

Indu.

Hello Gurus,

 

I have three objects which are disbaled for reporting.

But I want to keep these objects reportable to sys admin at least.

 

please let me know if this can be achived anyhow.

 

Thanks 

  • April 06, 2013
  • Like
  • 0

How can I get the Name, Company, Phone Website and the description from the last (Most recent) 2 Task associated with the Lead. I do need all of the leads so Querying the Task Table and using Who does not work for me. 

 

I tried 

SELECT Id, Name, FirstName, LastName, Company, Website, Phone, (SELECT Description FROM Task limit 1 ) FROM Lead

 

Didn't understand relationship 'Task' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

 

How do you relate these two tables?

 

Hello,

 

I find myself stumped here, I am hoping you can help again.  I am trying to combine two shopping cart fields in a new custom formula field.

 

The first field is "pymt__Quantity__c" which is a number, the second is "pymt__Product_Code__c" which is text.  What I need to happen is this, if a customer ordered 2 GREENC (2 being the payment quantity and GREENC being the Product Code) it would populate the new field as 2:GREENC.  This is what I have tried but I get an error.  

 

pymt__Quantity__c & ":" & TEXT(pymt__Product_Code__c)

 

When creating the new field as an object in payment I get error: "Field pymt__Quantity__c does not exist. Check spelling.

 

When creating the new field as an object in shopping cart item I get error: "Incorrect parameter type for operator '&'. Expected Text, received a number.

 

Any help would be very appreciated.

 

I'm a newbie!  

 

 

Can we show images stored as Attachments on standard Account object to Partner and Customer Portal users?

Hi Folks,

 

I am running into an unexpected issue, I want to know how salesforce execute the Time Based Workflow queue.

 

Let me explain the issue in detail,

 

We are having some time based workflow(On Object X), which is executing 120 days before trigger runs, and this workflow is updating a Boolean Flag using field update action. This flag update causes the trigger to be fired on Object X. This trigger is inserting records for another object (lets say Y).

 

We are loading data of Object X (approx 800 records) using Apex Data loader (V23.0). After inserting records the Time Based Workflow Queue shows the the list of trigger actions needs to be fired before 120 days. Scheduled Date shown as "1/09/2011 12:00 AM".

 

I know, If the schedule date is already in past then Salesforce executes the action after records inserted.

 

Now, after executing all actions, I can see only 1 transaction is succedded and other are failed with error "Insert failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []"

The error is coming at the line where I am inserting the records for Object Y.

 

I am using Unlimited Edition and the per hour workflow time based action limit is 1000. My record counts is less than 1000 and still I can see there are 4 entries in debug log. Out of 4 only 1 succedded and other 3 are failing with the above mentioned error.

 

Thanks in advance!

 

Hi All,

 

Can I get any information on running Apex Data Loader using CLI on HP-UX Operating System ?

 

I have never used HP-UX OS and not sure If it is feasible or not to configure Data Loader using CLI on this syste,.

 

I believe some of you people having experience with this OS and salesforce.

 

Please reply with your inputs.

 

thanks in advance,

Hi,

 

We are having a issue with the File Input (attachment). Issue description is described below.

 

In the visualforce page, we have made a validation on the attachment for the size of 2 MB. Now conditions are as below:

 

          (i) If the uploaded attachment has size less than or equal to 2 MB then it works properly and attachment insertion proceed successfully.

          (ii) If the uploaded attachment has size greater than 2 MB and upto 25 MB then it gives proper error message from the controller.

          (iii) Issue arise in this situation. As the uploaded attachment size is greater then 25 MB then salesforce gives it's own error message 'Error : This file exceeds the maximum size limit of 25 MB.' and makes attachment null.

 

I tried to solve this on the client side with the jQuery. jQuery code worked properly in the html page and I was able to get the full filepath but as I merged that code in visualforce page then I just get the filename, not the exact file path and so unable to get size client side.

 

I want to make 2 MB size validation in all the scenarios.

 

Please share your views.

 

thanks,

crmtech21

Can we show images stored as Attachments on standard Account object to Partner and Customer Portal users?
Hi All,

I have a requirement where when a case is created via third party site to salesforce the details in the case description doesnt get the special characters such as ($,&,@!) which is coming as a space and not carried over , but when created a case manually then the special characters are visible. Please let me know if there is any way to accomodate the special characters on case description when details comes via third party site.

Thanks in Advance

I'm trying to pinpoint an error with a test class using a static variable for a query on Report. Given below test class:

@IsTest
private with sharing class Example_Test_Class {
    private static String testReportName = 'My Test Report';
    private static Report testReport = [SELECT Id FROM Report WHERE Name=:testReportName LIMIT 1];

    @IsTest(SeeAllData=true)
    private static myTestMethod() {
        // Access testReport.Id here
    }
}
Is this valid? I'm not getting any compiler errors but this feels like a possible code smell.
I created javascript to test Rest APIs to an application from Postman. I am now trying to convert or rewrite it to be used in Salesforce to do the same. I am having a hard time in doing so. Any suggestions?
  • January 21, 2020
  • Like
  • 0
Hi ,
I am new in devlopment side. Somebody help me to write Trigger but I do not how to write Trigger Handler. Please help..

My Trigger: 
 trigger populateParentAccount on account(after insert) {
      Account[] updates = new Account[0];
      Set<Id> accountIds = new Set<Id>();
      for(Lead record: [SELECT ConvertedAccountId, Agency_Account__c FROM Lead WHERE ConvertedAccountId = :Trigger.new ORDER BY ConvertedDate DESC]) {
        // Avoid multiple leads with same account 
        if(!accountIds.add(record.ConvertedAccountId)) { 
          updates.add(new Account(Id=record.ConvertedAccountId, ParentId=record.Agency_Account__c));
        }
      }
      update updates;
    }

 
Hi All,

We have a request to delete the record type in our organization. Is there any way to check the dependencies on record type and page layouts?

Any ideas or suggestions on this? Thanks!
I need to write a soql query for  DLRS that will return records with a date in the year prior to "last fiscal year." Is there soql syntax that will return "2 fiscal years ago"? 

My current query is 
Select ID from School_Report_Card__c WHERE School_Year_of_This_Report_Card__c = Last_Fiscal_year

But I need the year before that. Is this possible?

Has anybody a solution to do this. 

I need to open a path on our servers through salesforce, when clicking on a button or hyperlink, it should open the folder based out of a path + a input field from salesforce, to link to the right folder

map<string,string> custmap = new map<string,stirng>();(declared and initialised in the constructor)
 Example1:in Debug window the custmap values are :
 {Andrapradesh=5.0, Karnataka=3.0, Maharastra=2.5, Telangana=4.0}

//How to print the keyset and values :

 for(list<wrapper> s: custmap){
       system.debug(s.keyset());
        system.debug(s.Values());
     
      }

//wrapperclass 
public class wrapper{
public string statename;
public string rating;
}

Thanks
Deepika
I am trying to extract the data via data loader, I am looking for the following criteria.
First Name contains 0,1,2,3,4,5,6,7,8,9
How do I put this in the SQL query? 
Hi ,
 I need help in json.
When i try to create record using json i am getting error in $User.Id
[
	{
		"attributes": {
			"type": "Activity_Template__c"
		},
		"Name": "Expense test",
		"Assigned_To__c": $User.Id,
	}
]

I want to dynmically set the Assigned_To__c i.e whoever runs this json Assigned_To__c will contain there user id.

Thanks in advance
Hi fellow developers:

I am working on an apex trigger that will assign cases to certain groups/users based on the requirements from my boss.

What is really bothering me now is that when i ran the test class in sandbox it worked perfectly but when trying to deploy in production it gives me the following error:

First exception on row 2 with id 5003a00000xQsOrAAK; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
Stack Trace: Class.TestCaseTrigger.TestCaseStatusChange: line 101, column 1


the trigger code:
trigger CaseTrigger on Case (before update) {
    for(Case c:Trigger.New){
        // grab the version of this case before the update 
        Case oldcase = Trigger.oldMap.get(c.ID);
        // access the status before the update for this case 
        string old_status = oldcase.status;
        // access the status after the update for this case
        string new_status = c.status;
        if(old_status == 'Closed' && new_status != 'Closed'){
          // we only need to handle this scenario, for now
          boolean previous_onwer_isactive = [SELECT owner.isActive FROM case WHERE id = :oldcase.Id LIMIT 1].owner.isactive;
            if(previous_onwer_isactive==FALSE){
                // create the rules based on "Case Assignment Rule"
                string case_subject = [SELECT subject FROM case WHERE id = :c.id LIMIT 1].subject;
                string case_origin = [SELECT origin FROM case WHERE id = :c.id LIMIT 1].origin;
                string assigned_to_name; // a variable used to locate its corresponding ID later on
                string assigned_to_id;
                
                if((case_subject=='HCRC TR Files'||case_subject=='HCRC FY Files') && case_origin == 
                   'Email - Enrollment Process Intelligence'){
                       assigned_to_name = 'HCRC Files';
                }
                else if(case_origin == 'Email - Enrollment Process Intelligence'){
                    assigned_to_name = 'Enrollment Process Intelligence';
                }
                else if(case_origin == 'Email - Enrollment Reporting'){
                    assigned_to_name = 'Enrollment Reporting';
                }
                else if(case_origin == 'Email - Enrollment Support'){
                    assigned_to_name = 'Tim';
                }
                else if(case_origin =='Email - Elevate'){
                    assigned_to_name = 'Elevate';
                }
                else if(case_origin =='Email - Graduate Admission'){
                    assigned_to_name = 'Graduate Admission Case Queue';
                }
                else if(case_origin =='Email - Graduate Recruitment'){
                    assigned_to_name = 'Graduate Recruitment';
                }
                else if(case_origin =='Email - Graduate Visit'){
                    assigned_to_name = 'Graduate Visit Case Queue';
                }
                else if(case_origin =='Email - GR Admission Partner'){
                    assigned_to_name = 'GR Admission Partner';
                }               
                else if(case_origin =='Email - UG Admission Partner'){
                    assigned_to_name = 'UG Admission Partner';
                }
                else if(case_origin =='Olark Live Chat' || case_origin == 'Graduate SnapEngage Chat'){
                    assigned_to_name = 'Graduate Recruitment';
                }
                else if(case_origin =='Web'){
                    assigned_to_name = 'Enrollment Process Intelligence';
                }
                else if(case_origin =='Email - Undergraduate Admission'){
                    assigned_to_name = 'Undergraduate Admission';
                }
                else if(case_origin =='Email - Undergraduate International'){
                    assigned_to_name = 'Undergraduate International';
                }
                else if(case_origin =='Email - Undergraduate Visit'){
                    assigned_to_name = 'Undergraduate Visit';
                }                    
                else if(case_origin =='Form Assembly - Project Request'){
                    assigned_to_name = 'Enrollment Process Intelligence';
                }
                else if(case_origin =='Email - Undergraduate Transfer'){
                    assigned_to_name = 'Undergraduate Transfer';
                }                
                else if(case_origin =='Email-Academic Honesty'){
                    assigned_to_name = 'Academic Honesty';
                }                
                else{
                    c.addError('did not find a queue/person to assign to!');
                    break;
                }
                
                // only Tim is not a queue(Group object), so handled seperately
                if(assigned_to_name !='Tim'){
                    assigned_to_id = [SELECT id FROM group where name =:assigned_to_name LIMIT 1].id;
                }
                else{
                     assigned_to_id = '005j000000COiwwAAD';
                }
               
                c.OwnerId = assigned_to_id;

                                
            }
        }
        
        
    }
}

trigger test class:
@isTest
public class TestCaseTrigger {
    @isTest static void TestCaseStatusChange(){
        // set up the data
        // create an user(owner)
        
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];

        System.runAs (thisUser){
        
        User test_user = new User(ProfileId = [SELECT Id FROM Profile WHERE Name = 'Standard User'].Id,
                          LastName = 'James',
                          Email = 'cli112@gmail.com',
                          Username = 'newlbj@gmail.com',
                          CompanyName = 'TEST',
                          Title = 'title',
                          Alias = 'alias',
                          TimeZoneSidKey = 'America/Los_Angeles',
                          EmailEncodingKey = 'UTF-8',
                          LanguageLocaleKey = 'en_US',
                          LocaleSidKey = 'en_US',
                          isactive =  FALSE
                         );
        
        
        insert test_user;
            
        // create a case
        string test_user_id = [SELECT id from user where username='newlbj@gmail.com' limit 1].id;
        // 

        List<Case> testCases = new List<Case>();
        Case test_case1 = New Case(origin='Email - Enrollment Process Intelligence', subject = 'HCRC TR Files',
         status='Closed', IIT_Project_Name__c = 'Test Case1',ownerid = test_user_id);
        testCases.add(test_case1);
        Case test_case2 = New Case(origin='Email - Enrollment Process Intelligence', subject = 'different subject', 
            status='Closed', IIT_Project_Name__c = 'Test Case2',ownerid = test_user_id);
        testCases.add(test_case2);
        Case test_case3 = New Case(origin='Email - Enrollment Reporting', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case3',ownerid = test_user_id);
        testCases.add(test_case3);
        //Case test_case4 = New Case(origin='Email - Enrollment Support', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case4',ownerid = test_user_id);
        testCases.add(test_case4);
        Case test_case5 = New Case(origin='Email - Elevate', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case5',ownerid = test_user_id);
        testCases.add(test_case5);
        Case test_case6 = New Case(origin='Email - Graduate Admission', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case6',ownerid = test_user_id);
        testCases.add(test_case6);
        Case test_case7 = New Case(origin='Email - Graduate Recruitment', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case7',ownerid = test_user_id);
        testCases.add(test_case7);
        Case test_case8 = New Case(origin='Email - Graduate Visit', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case8',ownerid = test_user_id);
        testCases.add(test_case8);
        Case test_case9 = New Case(origin='Email - GR Admission Partner', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case9',ownerid = test_user_id);
        testCases.add(test_case9);
        Case test_case10 = New Case(origin='Email - UG Admission Partner', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case10',ownerid = test_user_id);
        testCases.add(test_case10);
        Case test_case11 = New Case(origin='Olark Live Chat', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case11',ownerid = test_user_id);
        testCases.add(test_case11);
        Case test_case12 = New Case(origin='Web', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case12',ownerid = test_user_id);
        testCases.add(test_case12);
        Case test_case13 = New Case(origin='Email - Undergraduate Admission', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case13',ownerid = test_user_id);
        testCases.add(test_case13);
        Case test_case14 = New Case(origin='Email - Undergraduate International', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case14',ownerid = test_user_id);
        testCases.add(test_case14);
        Case test_case15 = New Case(origin='Email - Undergraduate Visit', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case15',ownerid = test_user_id);
        testCases.add(test_case15);
        Case test_case16 = New Case(origin='Form Assembly - Project Request', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case16',ownerid = test_user_id);
        testCases.add(test_case16);
        Case test_case17 = New Case(origin='Email - Undergraduate Transfer', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case17',ownerid = test_user_id);
        testCases.add(test_case17);
        Case test_case18 = New Case(origin='Email-Academic Honesty', subject = 'HCRC TR Files', 
            status='Closed', IIT_Project_Name__c = 'Test Case18',ownerid = test_user_id);
        testCases.add(test_case18);

        insert testCases;
            
        
        // select all the test cases and then update them to status as "In Progress"
        List<Case> newstatusCases = [SELECT origin, subject, Status, ownerid FROM case WHERE IIT_Project_Name__c LIKE 'Test Case%'];
            
        for(Case c : newstatusCases){
            c.Status = 'In Progress';
        }
            
        system.debug('Size of newstatusCases: ');
        system.debug(newstatusCases.size());

        update newstatusCases;
        
            
        Test.startTest();

        // test1 : 'Email - Enrollment Process Intelligence' --> 'HCRC Files'
        Case inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case1' LIMIT 1];
        string test1_owner_id = inserted_test_case.OwnerId;
        
        test2 : 'Email - Enrollment Process Intelligence' --> 'Enrollment Process Intelligence'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case2' LIMIT 1];
        string test2_owner_id = inserted_test_case.OwnerId;
        
        // test3 : 'Email - Enrollment Reporting' --> 'Enrollment Reporting'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case3' LIMIT 1];
        string test3_owner_id = inserted_test_case.OwnerId;
            
            
        test4 : 'Email - Enrollment Support' --> 'Tim'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case4' LIMIT 1];
        string test4_owner_id = inserted_test_case.OwnerId;
        
        // test5 : 'Email - Elevate' --> 'Email - Elevate'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case5' LIMIT 1];
        string test5_owner_id = inserted_test_case.OwnerId;
        
        // test6 : 'Email - Graduate Admission' --> 'Graduate Admission Case Queue'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case6' LIMIT 1];
        string test6_owner_id = inserted_test_case.OwnerId;

        // test7 : 'Email - Graduate Recruitment' --> 'Graduate Recruitment'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case7' LIMIT 1];
        string test7_owner_id = inserted_test_case.OwnerId;

        // test8 : 'Email - Graduate Visit' --> 'Graduate Visit Case Queue'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case8' LIMIT 1];
        string test8_owner_id = inserted_test_case.OwnerId;            
 
        // test9 : 'Email - GR Admission Partner' --> 'GR Admission Partner'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case9' LIMIT 1];
        string test9_owner_id = inserted_test_case.OwnerId; 
            
        // test10 : 'Email - UG Admission Partner' --> 'UG Admission Partner'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case10' LIMIT 1];
        string test10_owner_id = inserted_test_case.OwnerId;

        // test11 : 'Olark Live Chat' --> 'Graduate Recruitment'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case11' LIMIT 1];
        string test11_owner_id = inserted_test_case.OwnerId;

        // test12 : 'Web' --> 'Enrollment Process Intelligence'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case12' LIMIT 1];
        string test12_owner_id = inserted_test_case.OwnerId;            

        // test13 : 'Email - Undergraduate Admission' --> 'Undergraduate Admission'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case13' LIMIT 1];
        string test13_owner_id = inserted_test_case.OwnerId;            

        // test14 : 'Email - Undergraduate International' --> 'Undergraduate International'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case14' LIMIT 1];
        string test14_owner_id = inserted_test_case.OwnerId;            

        // test15 : 'Email - Undergraduate Visit' --> 'Undergraduate Visit'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case15' LIMIT 1];
        string test15_owner_id = inserted_test_case.OwnerId;            
        
        // test16 : 'Form Assembly - Project Request' --> 'Enrollment Process Intelligence'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case16' LIMIT 1];
        string test16_owner_id = inserted_test_case.OwnerId;              
            
        // test17 : 'Email - Undergraduate Transfer' --> 'Undergraduate Transfer'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case17' LIMIT 1];
        string test17_owner_id = inserted_test_case.OwnerId;              
            
        // test18 : 'Email-Academic Honesty' --> 'Academic Honesty'
        inserted_test_case = [SELECT origin, subject, status, ownerid FROM case WHERE IIT_Project_Name__c = 'Test Case18' LIMIT 1];
        string test18_owner_id = inserted_test_case.OwnerId;            
            
        
            
        Test.stopTest();

            
            
            
            
            
        // Tests validations

        string test1_correct_owner_id = [SELECT id FROM group where name = 'HCRC Files' LIMIT 1].id;
        System.assertEquals(test1_owner_id,test1_correct_owner_id);

        string test2_correct_owner_id = [SELECT id FROM group where name = 'Enrollment Process Intelligence' LIMIT 1].id;
        System.assertEquals(test2_owner_id,test2_correct_owner_id);
            
        string test3_correct_owner_id = [SELECT id FROM group where name = 'Enrollment Reporting' LIMIT 1].id;
        System.assertEquals(test3_owner_id,test3_correct_owner_id);
            
        string test4_correct_owner_id = '005j000000COiwwAAD';
        System.assertEquals(test4_owner_id,test4_correct_owner_id);

        string test5_correct_owner_id = [SELECT id FROM group where name = 'Elevate' LIMIT 1].id;
        System.assertEquals(test5_owner_id,test5_correct_owner_id);
        
        string test6_correct_owner_id = [SELECT id FROM group where name = 'Graduate Admission Case Queue' LIMIT 1].id;
        System.assertEquals(test6_owner_id,test6_correct_owner_id);

        string test7_correct_owner_id = [SELECT id FROM group where name = 'Graduate Recruitment' LIMIT 1].id;
        System.assertEquals(test7_owner_id,test7_correct_owner_id);

        string test8_correct_owner_id = [SELECT id FROM group where name = 'Graduate Visit Case Queue' LIMIT 1].id;
        System.assertEquals(test8_owner_id,test8_correct_owner_id);

        string test9_correct_owner_id = [SELECT id FROM group where name = 'GR Admission Partner' LIMIT 1].id;
        System.assertEquals(test9_owner_id,test9_correct_owner_id);

        string test10_correct_owner_id = [SELECT id FROM group where name = 'UG Admission Partner' LIMIT 1].id;
        System.assertEquals(test10_owner_id,test10_correct_owner_id);            

        string test11_correct_owner_id = [SELECT id FROM group where name = 'Graduate Recruitment' LIMIT 1].id;
        System.assertEquals(test11_owner_id,test11_correct_owner_id);            
            
        string test12_correct_owner_id = [SELECT id FROM group where name = 'Enrollment Process Intelligence' LIMIT 1].id;
        System.assertEquals(test12_owner_id,test12_correct_owner_id);
        
        string test13_correct_owner_id = [SELECT id FROM group where name = 'Undergraduate Admission' LIMIT 1].id;
        System.assertEquals(test13_owner_id,test13_correct_owner_id); 
            
        string test14_correct_owner_id = [SELECT id FROM group where name = 'Undergraduate International' LIMIT 1].id;
        System.assertEquals(test14_owner_id,test14_correct_owner_id);              
            
        string test15_correct_owner_id = [SELECT id FROM group where name = 'Undergraduate Visit' LIMIT 1].id;
        System.assertEquals(test15_owner_id,test15_correct_owner_id);              
        
        string test16_correct_owner_id = [SELECT id FROM group where name = 'Enrollment Process Intelligence' LIMIT 1].id;
        System.assertEquals(test16_owner_id,test16_correct_owner_id);              
            
        string test17_correct_owner_id = [SELECT id FROM group where name = 'Undergraduate Transfer' LIMIT 1].id;
        System.assertEquals(test17_owner_id,test17_correct_owner_id);              
            
        string test18_correct_owner_id = [SELECT id FROM group where name = 'Academic Honesty' LIMIT 1].id;
        System.assertEquals(test18_owner_id,test18_correct_owner_id);  
             
            // new_case.OwnerId;
    }
    }
}

 
Hello, I have a daily-scheduled-import of several new records, and names come in with inconsistent capitalization. I want my before insert trigger to make all the names appear normal (first letter of each name capital, the rest lower case.) I found code so far which does this but it leaves it as a list. How can this return a normal string of the name, with first then last name, in the normal format I want? 

String s;
     s = 'joHN JONSOn';
String [] lines = s.split('\n');
integer j = 0;
            for (String line:lines) {
String [] words = line.split(' ');
integer i = 0;
                for (String word:words) {
                    words[i] = word.trim().tolowercase().capitalize();
                    i++;
                }
                lines[j] = String.join(words,' ');
                j++;
                s = string.valueof(lines);
                system.debug(s);
            }