• Shrey Tyagi
  • NEWBIE
  • 60 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 8
    Replies
Hi Everyone,
    I have a situation in which I am trying to push an apex invocable code (used by a process builder) in production . Now the process flow gets deployed as inactive flow . So in order to get coverage for my apex invocable , I am using following test class to fire the invocable . Important lines are marked in bold. Now when I run this , it does not throw any error and says 0/0 methods passed. Can someone please help me with this?
///////////////////Test Class//////////////////////////////
@isTest
private class CanInvocableHelperTest {

    @testSetup static void setup1() {

        Id currentUser = UserInfo.getUserId();
        Opportunity opp = TestUtil.setupTestData();
        opp.StageName = 'Closed Won';
        opp.Sub_Stage__c = 'Awarded';
        opp.Qty_of_CANs_Required__c = 1;
        opp.Did_Price_Change__c='No';
        update opp;
        //Updating Opportunity creates 1 can record.
        //Retrive the related CAN record using SOQL.
        CAN__c theCan = [SELECT Opportunity__c,Contract_Manager__c,Status__c,Awarded_Project__c FROM CAN__c Where Opportunity__c =:opp.Id];
        theCan.Contract_Manager__c = currentUser;
        theCan.Status__c='CP Setup';
        theCan.Awarded_Project__c='111111111';
        List<Id> TestCanIdList= new List<Id>();
        TestCanIdList.add(theCan.Id);
        // Change status to simulate process flow firing mechanism.As process flow is inactive.
        update theCan;

        Test.startTest();
        //calling invocable method here with can id
        CreateProjectRecord.ProjectRecordCreateMethod(TestCanIdList);

        
        Test.stopTest();
        }
}


///////////////////Invocable apex class////////////////////////////
public class CreateProjectRecord{ 
    
    @InvocableMethod     
    public static void ProjectRecordCreateMethod(List<Id> CanIds)     
    {        
        //Logic here
    }
}
Hi Evryone ,
   I have this pretty simple code given below. Now everything works well here. What i want to do is, rather than the record being displayed as a 1 row with 3 columns. I want it to be displayed as 1 column 3 rows. Can anyone please help me with this?

Current Display Format : Name, Narrative Technical, Narrative Staffing
Desired Display Format : Name 1
                                             Narrative Technical 1
                                             Narrative Staffing 1
                                         Name 2
                                             Narrative Technical 2
                                             Narrative Staffing 2

<apex:page standardController="Project_Form__c" recordSetVar="ProjectForms">
    <apex:sectionHeader title="Form History"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />

            <apex:pageBlockSection title="Selected Project Review Forms" columns="1">
                 <apex:pageBlockTable value="{!selected}" var="form" columns="3">
                    <apex:column value="{!form.name}"/>
                    <apex:column value="{!form.Narrative_Technical__c}"/><br></br>
                    <apex:column value="{!form.Narrative_Staffing__c}"/><br></br>
                  </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Hi ,
 I have this code below. I need to add values to Map<Id,List<Id>>, it is giving an error , can anyone pleas ehelp?


trigger Project_Risk_Review_Trigger on Project_Risk_Review__c (after insert,after update) {
   
   
         // Create a new list of sharing objects for Project_Risk_Review
         List<Project_Risk_Review__Share> ProjectRiskReviewShrs  = new List<Project_Risk_Review__Share>();

         Map<Id,List<Id>> OldSharesMap=new Map<Id,List<Id>>();
         // Declare variables for super user sharing.
         Project_Risk_Review__Share SuperUserShrDvp;
         Project_Risk_Review__Share SuperUserShrDelegate;
         Project_Risk_Review__Share SuperUserShrProjectDirector;
         Project_Risk_Review__Share SuperUserShrChairReviewer;
         for(Project_Risk_Review__c NewAssessment : trigger.new){
                  
                  Project_Risk_Review__c oldReview = Trigger.oldMap.get(NewAssessment.ID);                  
                  if(NewAssessment.DVP__c != Null && ((Trigger.IsInsert && Trigger.IsAfter)||(Trigger.IsUpdate && Trigger.IsAfter && (NewAssessment.DVP__c !=oldReview.DVP__c)))){
                      // Instantiate the sharing objects
                      SuperUserShrDvp = new Project_Risk_Review__Share();
                      // Set the ID of record being shared
                      SuperUserShrDvp.ParentId = NewAssessment.Id;
                      // Set the ID of user or group being granted access
                      SuperUserShrDvp.UserOrGroupId =NewAssessment.DVP__c;
                      SuperUserShrDvp.AccessLevel = 'edit';
                      // Set the Apex sharing reason for DVP
                      SuperUserShrDvp.RowCause = Schema.Project_Risk_Review__Share.RowCause.PRAS_Super_Users_R_W_Access__c;
                      // Add objects to list for insert
                      ProjectRiskReviewShrs.add(SuperUserShrDvp);
                      if(Trigger.IsAfter && Trigger.IsUpdate){
                        OldSharesMap.put(oldReview.ID,oldReview.DVP__c);
                      }
                  }
Need help with following SOQL

Select Id,Name from Opportunity where
name != null
and
 (
    Id In (Select OpportunityId FROM OpportunityTeamMember where Name LIKE '%shrey%')
    OR
    (Proposal_Leader__r.Name='Shrey Tyagi')
 )
order by Name asc nulls first limit 50

Error : MALFORMED_QUERY: Semi join sub-selects are only allowed at the top level WHERE expressions and not in nested WHERE expressions.
Hi Everyone ,
         I have an apex class whose constructor is calling a method . The call out is done after setting 1 parameter . The code is given below:

Constructor:

  public ProposalSearchControllerModified() {
     //String variable for soql
      soql = 'Select Id,Name from Opportunity where name != null';
     //executing SOQL AND PAASING VALUES TO THE LIST.
     Opportunities = Database.query(soql + ' order by ' + sortField + ' ' + sortDir+ ' Limit 50');
     //USING 1ST RECORD OF LIST TO EXECUTE ANOTHE METHOD - CLEAR Order
     DetailRecordId=Opportunities[0].Id;    
    ClearOrder();
  }


Test Class Code:

@istest
public class ProposalSearchControllerModifiedTest{
    public static testmethod void ProposalSearchMethod(){
         
         
         PageReference pageRef = Page.ProposalSearchModified;
         pageRef.getParameters().put('Name', 'Te');
         pageRef.getParameters().put('OpportunityID', '0');
         pageRef.getParameters().put('SolicitationNo', '0');
         pageRef.getParameters().put('ProposalNo', '0');
         
         Test.setCurrentPage(pageRef);
         ProposalSearchControllerModified cs=new ProposalSearchControllerModified();
         String sd=cs.sortDir;
         String sf=cs.sortField;
         String ds=cs.debugSoql;
         list<String> ls=cs.Stages;
         list<String> ls1=cs.SubStages;
         list<String> ls2=cs.FiscalYearValues;
         
         cs.toggleSort();
         cs.runQuery();
         cs.runSearch();
         cs.reset();
         
         
    
    }
}​



Error Message:

System.ListException: List index out of bounds: 0

Error is thrown when highlighted line in code above is covered through test class.
Hi Everyone ,
        I have this query and it works well. 

select Id,Name,StageName,Sub_Stage__c,Opportunity_ID__c,Account.Name,Proposal__r.Name,(Select Project__c From Awarded_Projects__r where Name != null Limit 1) from Opportunity where Name!= null order by Name asc limit 30

Now I want to order this query by  Project __c field that is fetched from the Child Record of :Awarded_Project__r. Can anyone please help me with the syntax?


Thanks 
Shrey Tyagi