• DeveloperSud
  • SMARTIE
  • 764 Points
  • Member since 2015

  • Chatter
    Feed
  • 25
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 10
    Questions
  • 127
    Replies
Ok, so in a process builder i have to create a new criteria that checks if the Case owner has changed (which i have this part) but also that the owner is not a Queue that part i'm stuck on

can anyone help?
I have built a trigger that should fire when an Opportunity is created or updated in a particular way.

I was so focused on the update part that I never tested the on insert part until today.

Everything else in trigger works but I can't figure out why it does not execute when the Opp is first created.

Here is the complete trigger:
trigger createOqNew on Opportunity (after insert, after update) 

//trigger
{ 
   
    // try
    try{
           
        Id recordTypeId =
        Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CDARS_ICS_Prospect').getRecordTypeId();
        
        List <Open_Quarter__c> createOpenQuarter = new List <Open_Quarter__c>();
        List <Open_Quarter__c> deleteOpenQuarter = new List <Open_Quarter__c>();
        
        // for loop 1
        for (Opportunity opportunityList : Trigger.new) {   
            
            // if loop 1
            if (opportunityList.RecordTypeId == recordTypeId) {
                
                // if loop 2
                if (Trigger.isInsert 
                    || (Trigger.isUpdate && opportunityList.Estimated_Start_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Start_Quarter__c)
                    || (Trigger.isUpdate && opportunityList.Estimated_Finish_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Finish_Quarter__c)){
                                          
                    Decimal year = opportunityList.Start_Year__c;
                    Decimal quarter = opportunityList.Start_Quarter__c;
                    Decimal span = opportunityList.Quarters_Spanned_op__c;
                    
                    //for loop 2
                    for (Integer counter = 0; counter < span; counter++)
                    {
                        Open_Quarter__c oq           = new Open_Quarter__C();
                        oq.Amount_Per_Quarter_oq__c  = opportunityList.Amount_per_Quarter_op__c;
                        oq.Close_Date_oq__c          = opportunityList.CloseDate;
                        oq.Name                      = year+'-'+'Q'+quarter;
                        oq.Opportunity_Name_oq__c    = opportunityList.Id;
                        
                        createOpenQuarter.add(oq);
                        quarter++;
                        
                        // if loop 3
                        if (quarter > 4) {
                            quarter = 1;
                            year++;
                        } //end if loop 3                       
                    } //end for loop 2      
                } //end if loop 2
            } //end if loop 1
        } //end for loop 1
        deleteOpenQuarter.addAll ([SELECT Id, Name FROM Open_Quarter__c WHERE Opportunity_Name_oq__c IN :trigger.newMap.keySet()]);
        
        // if loop 4
        if (deleteOpenQuarter.isEmpty()==false){
            Database.delete (deleteOpenQuarter,false);
        } // end if loop 4
        
        // if loop 5
        if(createOpenQuarter.isEmpty()==false){
            Database.insert (createOpenQuarter,false);
        } // end if loop 5
    } // end try
    
    //catch
    catch (Exception e){
        //e.getMessage()
            //e.getLineNumber()
            throw e;
    } // end catch
} // end trigger
It seems like it should work on insert but it does not. It only works on update.

Any suggestions?

Steve
 
I have a parent object and child object, in which a parent record shouldn't have duplicate child records.the following trigger is working fine but it is checking only the records in the database.

But my issue is? user is inserting two duplicate records at a time using .csv file and since my trigger is only validating the records in the database.
hence these duplicate records are also getting inserted.

How can I check duplicate in the .csv file itself ? or how to overcome this issue.

Can any one help me on this.
Trigger:
trigger BeatNameDuplicateCheck on Beat_TSE_Mapping__c (before insert, before update) {
        set<Id>TSEID= new set<ID>();
        set<string>bitname=new set<string>();
        map<string,Beat_TSE_Mapping__c> bitmap= new map<string,Beat_TSE_Mapping__c> ();
               for(Beat_TSE_Mapping__c beat:Trigger.new)
        {
            TSEID.add(beat.TSE_Code__c);
            bitname.add(beat.Beat_Name__c); 
        }
        if (!TSEID.isEmpty() ){
             List<Beat_TSE_Mapping__c> TSElist=new List<Beat_TSE_Mapping__c>();
        TSElist=[select id,Beat_Name__c,TSE_Code__c from Beat_TSE_Mapping__c where Beat_Name__c In: bitname and TSE_Code__c In: TSEID];
                       
        if (TSElist.size()>0) {
            for(Beat_TSE_Mapping__c beat:TSElist)
            {
              bitmap.put(beat.Beat_Name__c, beat);
            }     
        } 
                  }
        for (Beat_TSE_Mapping__c beat:Trigger.new)
                    {
            If (bitmap.containsKey(beat.Beat_Name__c ))
            {
                beat.Beat_Name__c.AddError('Beat Name Already Exist. Please try with another BeatName. ');
           }
        } 
}
Hi,

I have a multi select picklist field on vf page. I am rendering text field based on the value in multi picklist. Now i want to render other picklist field based on multipicklist value(with different condition). Since Iam already rendering one field i have written onchange event. now i cant use the same event and write another event for the same tag. How can I render two fields onchange of first field(two fields should be rendered with two conditions)? Please help me to achieve this scenario.

Thanks. 
  • December 13, 2017
  • Like
  • 0
I am trying to display an alert with a visual force page when two picklist fields are null. Here is my code, which is not working:

<apex:page standardController="Lead" rendered="{!NOT(ISNULL(TEXT(Lead.Egg_Donor_Status__c)))} && {!NOT(ISNULL(TEXT(Lead.Sperm_Donor_Status__c)))} " >
 <script type="text/javascript">
     {
         window.alert("Please request that Client send a copy of their Donor Eligibility document.");
     }
 </script>

</apex:page>

I get the following error: 
Error: Donor_Eligibility_Paperwork_Alert line 1, column 96: Element type "apex:page" must be followed by either attribute specifications, ">" or "/>"
Error: Element type "apex:page" must be followed by either attribute specifications, ">" or "/>".

I am basing this code on a tip found here: https://developer.salesforce.com/forums/?id=906F000000097KLIAY 
Hi all,

I have this VF page, which displays some fields in columns, rendered by a field value.
The only problem i encounter is that the records that are not shown because of the rendering, sstill produce a blank line.
How do i get the blank lines to not show up on the VF page.

This is de code
<apex:page standardController="Discount__c" recordSetVar="Discounts" >
   <apex:form >
   <apex:pageBlock rendered="{!If(Discount__c.Status__c !='Draft', true, false)}" title="Draft discounts">
        <apex:pageBlockTable value="{!Discounts}" var="a" >
        <apex:column headerValue="Name">        
        <apex:outputLink rendered="{!If(a.Status__c =='Draft', true, false)}" target="_blank" value="/{!a.id}">{!a.Name}</apex:outputLink>
        </apex:column>
        <apex:column headerValue="Status">
        <apex:outputText value="{!a.Status__c}" rendered="{!If(a.Status__c =='Draft', true, false)}"></apex:outputtext>
        </apex:column>
        <apex:column headerValue="API">
        <apex:outputText value="{!a.APIPartner__r.Name}" rendered="{!If(a.Status__c =='Draft', true, false)}"></apex:outputtext>
        </apex:column>
        <apex:column headerValue="MP User">
        <apex:outputText value="{!a.MP_User__r.Name}" rendered="{!If(a.Status__c =='Draft', true, false)}"></apex:outputtext>  
        </apex:column>
        <apex:column headerValue="Ingansdatum">
        <apex:outputText value="{0,date,dd'/'MM'/'yyyy}" rendered="{!If(a.Status__c =='Draft', true, false)}">
        <apex:param value="{!a.Discount_Start_Date__c}" /> 
        </apex:outputText>
        </apex:column>
        <apex:column headerValue="Ingediend door">
        <apex:outputText value="{!a.CreatedBy.Name}" rendered="{!If(a.Status__c =='Draft', true, false)}"></apex:outputtext>  
        </apex:column>
      </apex:pageBlockTable>
    </apex:pageBlock>
   </apex:form>         
</apex:page>
And this the output with the empty rows

User-added image

Regards
Chiel

User-added image
This code is a sample code in Trailhead to be run on Anonymous window. I get below error always. I tried removing the space and retyping those words. But still I'm getting this error in same or someother line. Let me know a solution for this problem.

"Error: Compile Error: Invalid identifier '    BillingCity'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_', or unicode characters from U+0080 to U+FFFE. at line 5 column 1"

Hi All,

I need a trigger that when the Opportunity Product "line description" field is created or edited, the related Quote line item object "Description" field should also be created or updated. So basically,
A) Object = Opportunity Product 
Field = Line Description
B) Object = Quote Line Item 
Field = Line Description
Trigger on new or update
Field on object A , should be populated on Object B's field 

Can anyone help please?
  • May 04, 2017
  • Like
  • 0
Friends, I have created a visual force page with cancel button. but when i click cancel button the page ask me to fill  required fields. How Can i Overcome this . My requirement is when i click cancel button it has to go list view page. 

Here My code
Apex:

Public Pagereference docancel(){      
    PageReference pageRef = new PageReference('/001/o');   
    pageRef.setRedirect(true);
    return pageRef;   
    }
Hello Developers...I have a custom object named Products and it is displayed as list. When I click on the name field under list, it should navigate to the detail page and it can be achieved using Hyperlink method. Can anyone suggest how to do that.
Thanks in advance
Sumanth Kumar
Hello. I am having an issue with UserInfo.getUserName() apparently not returning the expected result in a query inside an Apex class. The code is as follows:

public class MACTicketsByDoctorController {

    private String sortOrder = 'Bug_Open_days__c';
    private String doctorName = 'Greg Thompson';
        
    public List<SFDC_Ticket__c> getTickets() {
        
        List<SFDC_Ticket__c> results = Database.query(
            'SELECT Id, Title__c, MCS_Assignment__c, CreatedDate, Medical_Resource_Assignment__r.UserName, Total_Business_Days_Open__c, Status__c ' +
            'FROM SFDC_Ticket__c ' +
            'WHERE Medical_Resource_Assignment__r.Username = \''+UserInfo.getUserName()+'\'' +
            'AND Status__c = \'Closed\' ' +
            'ORDER BY ' + sortOrder + ' DESC ' +
            'LIMIT 10'
        );
        return results;
    }
}


This controller is being used in the following Visualforce page:
<apex:page controller="MACTicketsByDoctorController">
    <apex:form >
            
        <apex:pageBlock title="Open MAC Tickets" id="tickets_list">
            <!-- Tickets List -->
            <apex:pageBlockTable value="{! tickets }" var="tix" rendered="{!tickets.size>0}">
                <apex:column headerValue="Ticket">
                    <apex:outputLink target="_parent" value="/{!tix.Id}">{! tix.Title__c }</apex:outputLink>
                </apex:column>
                <apex:column headerValue="Assigned to" value="{! tix.MCS_Assignment__c }"/>
                <apex:column value="{! tix.CreatedDate }"/>
                <apex:column value="{! tix.Medical_Resource_Assignment__r.UserName }"/>
                <apex:column headerValue="Days open" value="{! tix.Total_Business_Days_Open__c }"/>               
                <apex:column value="{! tix.Status__c }"/>               
            </apex:pageBlockTable>
            <apex:pageMessage summary="No Tickets assigned" severity="info" rendered="{!tickets.size=0}" />
        </apex:pageBlock>
    </apex:form>
</apex:page>


Medical_Resource_Assignment__c is a lookup to User. 
if I replace line 
            'WHERE Medical_Resource_Assignment__r.Username = \''+UserInfo.getUserName()+'\'' +

with 
        'WHERE Medical_Resource_Assignment__r.Username = \'John.Doe@organization.com\'' +

then I get the correct result for John Doe Tickets. I wonder what am I doing wrong?

Thanks for any Help!
-Carlos
 

Hi guys, I want to show a pageBlock in the same VF page only after i press the outputLink. Hence, what should I put in outputLink so that when I press the link, it will direct me to the pageBlock that I want. Or there are still another way except from outputLink.

Now, the code below show the <apex:pageBlock title="Examination Result"> is stick with <apex:pageBlock title="Grade and Result" >. But what I want is after I press View, it will show the Grade and Result in the same VF page but without Examination Result pageBlock.

<apex:pageBlock title="Examination Result" rendered="{!showRecords}" >
	    <!--apex:pageBlock title="Examination Result"-->
	        <table>
	            <tr>
	                <td><apex:outputLabel >Current Date:</apex:outputLabel></td>
	                <td><apex:outputText value="{!myCurrentDate}"/></td>
	            </tr>
	         </table>   
		    <apex:outputPanel>	    
				    <apex:pageBlockTable value="{!resultList}" var="rl">
				    	
					    <apex:column value="{!rl.Exam_Date__c}"/>
					    <apex:column value="{!rl.Exam_Token__r.Exam_Type__c}"/>
					    <apex:column value="{!rl.Exam_Token__r.Proficiency_Level__c}"/>
					    <apex:column value="{!rl.Exam_CorrectAns__c}"/>
					    <apex:column value="{!rl.Exam_Token__r.Total_Question__c}"/>
					    <apex:column value="{!rl.Exam_Score__c}"/>
				        <apex:column >
				        	<apex:facet name="header">Grade and Result</apex:facet>
				        	<apex:outputLink value="/" >View</apex:outputLink>		                  
				        </apex:column>
				    </apex:pageBlockTable>
		    </apex:outputPanel > 
		</apex:pageBlock>


			<apex:pageBlock title="Grade and Result" >
			    <apex:outputPanel id="myPreviousResult">
			        <h3>Hello, {!$User.FirstName} {!$User.LastName}</h3>        
			    </apex:outputPanel>
			                 
			</apex:pageBlock>
Thanks!!!
Hi,

Can anyone help me to fix this issue,here am attaching the test class which am able to cover 50%,just help me out to cover the rest.
 
//trigger code
trigger UpdateTotalAmount on Opportunity (after insert,after update) {
     clsUpdateAccount.updateAccount(Trigger.new);
}

//APEX Class
public class clsUpdateAccount{
    public static void updateAccount(List<Opportunity> lstOpportunities) {
         List<Id> lstAccountIDs = new List<Id>();
         for(Opportunity opp: lstOpportunities) {
           lstAccountIDs.add(opp.AccountId);
         }
         
         Map<Id, Account> mapAccount = new Map<Id, Account>([SELECT Id, Name, TotalAmount__c FROM Account WHERE Id =:lstAccountIDs]);

         List<Account> lstAccounts = new List<Account>();
         for(AggregateResult result: [SELECT SUM(Amount) Amt, AccountId FROM Opportunity GROUP BY AccountId, StageName Having AccountId IN :mapAccount.keyset() AND StageName = 'Closed Won' ]) { 
            Account acc = mapAccount.get((Id)result.get('AccountID'));
            acc.TotalAmount__c = (Decimal)result.get('Amt');
            lstAccounts.add(acc);
         }
         if(lstAccounts.size() > 0){
            update lstAccounts;
         }
    }
}
 
static testmethod void oppamount(){
    Test.starttest();
    Account acc = new Account(Name = 'testacc' ,TotalAmount__c = 1000);
     insert acc;
    
   Opportunity opp = new Opportunity(RecordTypeId = '012E0000000Dke9', Name = 'name', CloseDate = Date.today(),
                        StageName = 'Prospecting', AccountId = acc.id, Amount = 1000, ForecastCategoryName = 'nextlevel', 
                        Opportunity_Source__c='Marketing Campaign (Inbound)');
        insert opp;
    
    
    Account acc1 = [SELECT id, Sum_of_Opportunity_Amount__c FROM Account WHERE Id = :acc.Id];
    // Verification
    System.assertEquals(acc1.TotalAmount__c, opp.amount);
     
    Test.stopTest();
    }
But here am getting below error:--
System.AssertException: Assertion Failed: Expected: null, Actual: 1000

Thanks
 
Hello Everyone!
How do i write test class for the trigger below. 
Trigger AccountEventTrigger on Event (Before Insert) {
    
/******************************************************************************
It controlls the creation of Events from accounts which are yet to be approved.
*******************************************************************************/
    list<Id> accountIds = new list<Id>();
    Map<Id,Account> accMap = new Map<Id,Account>();
    for(Event Event: Trigger.new){
        if(Event.whatId != null && String.valueof(Event.whatId).startsWith('001'))
            accountIds.add(Event.whatId);
    }
    if(!accountIds.isEmpty()){
        for(Account acc : [select id,Submitted_for_Approval__c from Account where id in : accountIds]){
            accMap.put(acc.id,acc);
        }   
        for(Event Event: Trigger.New){
            if(Event.whatId != null && accMap.containsKey(Event.whatId) && accMap.get(Event.whatId).Submitted_for_Approval__c!= false)
                Event.addError('New Event Cannot be Created');
        }
    } 
}
Hi All,

I'm trying create a visualpage that show the total amount of all opportunities closed.
In apex I did, but I don't know how I could display the results in visualpage.

My Apex code and visual page are like this:

APEX Code:
public class SumTotal {
    
        public Double SumOpportunities(){
        List<Opportunity> op = new List<Opportunity>();
        
        op = [SELECT Id, Name, Amount, StageName FROM Opportunity WHERE Amount > 0 AND StageName ='Fechado e ganho'];
        Double sum = 0.00;
            for(Opportunity opty : op){
                
                sum = sum + opty.Amount;
                System.debug(' Name : '+opty.Name+', Sum: '+soma + ', Opty Amount: '+opty.Amount);
            }
        return sum;
        System.debug('Sum: '+sum);
    }
}


VisualPage:

<apex:page showHeader="false" sidebar="false" standardStylesheets="false"
applyHtmlTag="false" applyBodyTag="false" docType="html-5.0" controller="SumTotal">
<html>
<head>
    <meta charset="utf-8"></meta>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"></meta>
    <title>Teste</title>
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
</head>
<body>
    <div class="container">
        <div class="jumbotron">
            <apex:dataTable value="{!Here I don't know what put}" var="sum">
            <apex:column>
            <apex:facet name="header">Product</apex:facet>
            <apex:outputText value="{!Here I must display the results of the variable}" />
            </apex:column>
        </apex:dataTable>
        </div>

Thanks
Rafael
    </div>
</body>
</html>

</apex:page>
suppose we choose 10 from picklist the the table should dispaly 10 records and if we choose 20 then the table updates to display 20 records.
Hi

I want to write a test class to increase code coverage for below mention trigger.
Can anyone help.
trigger paymenttermUpdate on Account (after update) {
    set<Id> acctIds = new set<Id>();
    map<Id, Account> mapAccount = new map<Id, Account>();
    list<Payment_Terms__c> listContact = new list<Payment_Terms__c>();
    
    for(Account acct : trigger.new) {
        acctIds.add(acct.Id);
        mapAccount.put(acct.Id, acct);
    }
    
    listContact = [SELECT Name, Payment_Terms__c,Account__c FROM Payment_Terms__c WHERE Account__c IN : acctIds];
    
    if(listContact.size() > 0) {
        for(Payment_Terms__c con : listContact) {
            con.Name = mapAccount.get(con.Account__c).Payment_Term_on_account_picklist__c;
            con.Payment_Terms__c = mapAccount.get(con.Account__c).Payment_Term_on_account_picklist__c;
        }
        update listContact;
    }
}

 
i have some requirement where i need a pick list on my VF page , pick  
   list contains all  objects.   based on this pick list value i want to  
   display all fields of appropriate object. for example if i select  
   Account from  pick list then it should show all its fields in the  
   page. please tell me how to do this & send some sample code 
trigger updateOpportunty on Event (after update) {
    
    List<Id> OpportuntyIds=new List<Id>();
    List<Opportunity> OpportunitysToUpdate =new List<Opportunity>();
    for(Event e:trigger.new){
            if(String.valueOf(e.whatId).startsWith('006') == TRUE)
            if((e.subject).contains('First Meeting'))
                        {//check if the task is associated with a Opportunty
                OpportuntyIds.add(e.whatId);
            }
    }
    Map<Id,Opportunity> OpportunityMap = new Map<Id,Opportunity>([SELECT Id,Meeting_Initially_Scheduled_Date__c FROM Opportunity WHERE Id IN :OpportuntyIds]);
    
    For (Event e:trigger.new){
        Opportunity opp = OpportunityMap.get(e.whatId);
        opp.Meeting_Initially_Scheduled_Date__c = e.Initially_Scheduled__c;
        OpportunitysToUpdate.add(opp);
    }
    
    try{
        update OpportunitysToUpdate;
    }catch(DMLException e){
        system.debug('Opportunitys were not all properly updated.  Error: '+e);
    }
}
Hi all,

i am new here is sfdc i want to know is there any automatic functionality in sf when the owner of account is changed its related contact owner is changed. if yes can we disable it

Hi Team,
I have salesforce flow embeded inside a visualforce page.I am getting this error when the page is opening.
This page has an error. You might just need to refresh it.
Error during LWC component connect phase: [Failed to initialize a component [Cannot read properties of undefined (reading '$getComponent$')]]
Failing descriptor: {flowruntime:lwcBody}
did any one encounter the same?

What are options available inherit css styles in child component from parent in LWC.
Hi All,

I was going through the lightning community limitations from the salesforce document and as it is mentioned there "The Create New option for lookups isn’t supported in Customer Service communities" but when I use the customer service template I can see the new options are appearing in the lookup fields. Can someone please clarify the confusion or am I doing something wrong here? Please let me know if you have encountered the same in lightning community customer service templates.
Hi All,

I was referring the salesforce documentation for lightning:input type="email" .There it is mentioned When multiple email is used, the email field expects a single email address or a comma-separated list of email addresses. Example, my@domain.com,your@domain.com with or without a space after the comma.Is it possible to use type="email" when there is a need to enter multiple email id.I have tried to enter multiple emails with comma separation but it is giving me error as "You have entered an invalid format.".
Hi All,

I wanted to know how authentication can be maintained when a third party application make soap callout to salesforce to fetch data from salesforce.A WSDL file has been shared to the thrid party application in order to make a callout but how salesforce will understand that the callout is coming from the third party application only and not from other sources.Which all good practices we should follow?
Hi ,
Is there anyone worked on UserRole object before.I have a requiremnt where I have to change the ParentRole for the partner users role,What I understood we can do this with userRole object but the problem is it is not allowing me to update the parentRole Id field for the  UserRole objecteven though in field description section it is showing up dateable.Anyone anybidea how that can be done? or any other suggestion?


User-added image
Hi Guys,

I have created a pageblock table where user can dynmically add and remove rows .In each rows I am using an input field .The problem I am facing while clicking the add row button its resetting the previous value entered in the previous row.Kindly help if anyone else faced the same problem .
<apex:page standardController="Account" extensions="AddnRemoveController" >
<apex:form id="f" >
<apex:pageMessages ></apex:pageMessages>
<div>
 <apex:pageBlock mode="maindetail" >
 <!-- <apex:variable value="{!0}" var="rowNumber" /> -->
  <apex:commandButton value="AddRow" action="{!addrow}" reRender="table">
  </apex:commandButton>
  <apex:commandButton value="Remove Row" action="{!removerow}" reRender="table">
  <!-- <apex:param value="" name="rowNum" assignTo="{!rowNum}" /> -->
  </apex:commandButton>
  
 
  <apex:pageBlockTable value="{!wrapList}" var="wrapVar" id="table">
  <!-- <apex:variable value="{!wrapVar.index}" var="rowNumber" /> -->
   <apex:column >{!wrapVar.index}</apex:column>
   <apex:column headervalue="{!wrapVar.act.Industry}">
    <apex:inputField value="{!wrapVar.act.Industry}" id="modalBankCountry"/>
   </apex:column>
  </apex:pageBlockTable>
   <apex:commandButton value="Save" action="{!saving}" />
 </apex:pageBlock>
 </div>
 </apex:form>
</apex:page>
 
<apex:page standardController="Account" extensions="AddnRemoveController" >
<apex:form id="f" >
<apex:pageMessages ></apex:pageMessages>
<div>
 <apex:pageBlock mode="maindetail" >
 <!-- <apex:variable value="{!0}" var="rowNumber" /> -->
  <apex:commandButton value="AddRow" action="{!addrow}" reRender="table">
  </apex:commandButton>
  <apex:commandButton value="Remove Row" action="{!removerow}" reRender="table">
  <!-- <apex:param value="" name="rowNum" assignTo="{!rowNum}" /> -->
  </apex:commandButton>
  
 
  <apex:pageBlockTable value="{!wrapList}" var="wrapVar" id="table">
  <!-- <apex:variable value="{!wrapVar.index}" var="rowNumber" /> -->
   <apex:column >{!wrapVar.index}</apex:column>
   <apex:column headervalue="{!wrapVar.act.Industry}">
    <apex:inputField value="{!wrapVar.act.Industry}" id="modalBankCountry"/>
   </apex:column>
  </apex:pageBlockTable>
   <apex:commandButton value="Save" action="{!saving}" />
 </apex:pageBlock>
 </div>
 </apex:form>
</apex:page>

 
Hi Guys,
I am working on a new topic where I need to create two mutually dependent picklist in a VFpage using same method used as actionsupport action.The situation is like there will be two picklist and a button to show the last selected value from the picklists. Two picklist will have same value and change in one's value will automatically change other's value too. While implementing it, the issue I am facing is :only the last picklist is controlling the situation means the value selected in the last picklist is displaying only .I am giving the sample code and look of the page.Kindly give me your advise how I can implement it using the same method so that the value change in one picklist will have a change on the other also.
<apex:page controller="exampleCon1x">
    <apex:form >
        <apex:outputPanel id="one11">
         <apex:selectList id="piclist1" value="{!selectedRecord}"  >
                  <apex:selectOption itemvalue="10" itemLabel="10"/>
                   <apex:selectOption itemvalue="20" itemLabel="20"/>
                   <apex:selectOption itemvalue="50" itemLabel="50"/>
                   <apex:selectOption itemvalue="100" itemLabel="100"/> 
                  <apex:actionSupport event="onchange" action="{!search}" reRender="one11"/>   
         </apex:selectList><p/>
        </apex:outputPanel>
        <apex:outputPanel id="two22">
        <apex:selectList id="picklist2" value="{!selectedRecord}"  >
                   <apex:selectOption itemvalue="10" itemLabel="10"/>
                   <apex:selectOption itemvalue="20" itemLabel="20"/>
                   <apex:selectOption itemvalue="50" itemLabel="50"/>
                   <apex:selectOption itemvalue="100" itemLabel="100"/> 
                  <apex:actionSupport event="onchange" action="{!search}" rerender="two22"/> 
        </apex:selectList><p/>
        </apex:outputPanel>

        <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
        
    <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="testing...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    <p>You have selected:</p>
                    <apex:dataList value="{!selectedRecord}" var="s">{!s}</apex:dataList>
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
    </apex:form>
</apex:page>
 
public class exampleCon1x{

    public String selectedRecord{get; set;}
    
                    
    public Pagereference Search()
    {
      return null;
    }         
                 
   public pageReference test(){
   return null;
   }   
}

User-added image
 
Hi Guys,
Need your help on the below situation.
I have a page which is showing "List of Cases" for my organisation.I have added a filter 'Status' so that it can refine the case list based on requirement.Status options are 'New' and 'Resolved' Cases and after choosing any one of the option if I hit the search button it will show the list of cases based on the status.If no option is selected by default it will show the all cases in the list.
Now the requirement is if I apply case filter status as 'new' and if it retuns 4 cases, after clciking any one of that case it should redirect to the case detail page and after clicking the 'back to cases' command link in case detail page it should redirect back to refined serach result (it should show all that 4 cases in the list not all the cases) .I am giving my code here .Please help .thanks!!!
<apex:page controller="testController100">
<apex:form >
<apex:outputPanel >
  <apex:pageBlock title="List Of Cases For My Test Organisation" >
    <apex:outputLabel ><b> Status : </b></apex:outputLabel>
       <apex:selectList value="{!caseStatus1}" size="1">
         <apex:selectOption itemvalue="NEW" />
         <apex:selectOption itemvalue="RESOLVED" />
       </apex:selectList>  
       <apex:commandButton value="search" action="{!search}" /> 
  </apex:pageBlock>
 </apex:outputPanel>    
 </apex:form>
 <!--show the List of Cases -->   
    <apex:form >
    <apex:outputPanel id="out1">
     <apex:pageBlock >
          <apex:pageBlockTable value="{!listofcases}" var="lstofcases">
           <apex:column >
             <apex:facet name="header" >
                <apex:commandLink value="Case" >   
            </apex:commandLink>             
          </apex:facet>  
        <apex:outputLink value="/apex/casedetail?id={!lstofCases.Id}" id="theLink0" >{!lstofcases.CaseNumber}</apex:outputLink> 
        </apex:column>
 
public with sharing class testController100 {
  
  public String caseStatus1{get;set;}
  
  public pagereference search(){ 
  return null;
  }
 
    // code to show list of cases
     public List<case> getlistofcases(){
      List<Case> listofcases=New List<Case>();
      if(caseStatus1=='NEW'){
      listofcases=[select casenumber,status,priority from case where status='New' order by status ASC];
     }
     else if(caseStatus1=='Resolved'){
     listofcases=[select casenumber,status,priority from case where status='Closed' order by status ASC];
     }
     else{
      listofcases=[select casenumber,status,priority from case where status='Closed' or status='New' order by status ASC];
     }
     return listofcases;
     }
    }
 
<!-- Case detail page-->
<apex:page standardController="case" extensions="testcontroller101">
<apex:form >
  <apex:outputpanel style="left-padding:600px" id="panelId">
            <apex:commandLink value="Back To Case" style="color:blue ;font-size:16px" action="{!backurl}" />
            <apex:pageBlock >
             <apex:pageBlockSection columns="2">
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Case #</apex:outputLabel>
                <apex:outputField value="{!CaseInfo.CaseNumber}" style="width:200px;"  id="BCname"/>
            </apex:pageBlockSectionItem>        
            <apex:pageBlockSectionItem >        
                <apex:outputLabel >Status</apex:outputLabel>
                <apex:outputField value="{!CaseInfo.Status}" style="width:200px;" id="CCategory"/>
            </apex:pageBlockSectionItem>
            </apex:pageblocksection>
            </apex:pageBlock>
  </apex:outputPanel>          
</apex:form>            
</apex:page>
 
public with sharing class testcontroller101 {

    public id caseId{get;set;}
    public Case CaseInfo { get; set; }
    
    public testcontroller101(ApexPages.StandardController stdController) 
    {
    caseId = stdController.getRecord().Id;
    if(caseId!=null)
        {
            CaseInfo=[ select casenumber,Id,status 
                  From Case where id=:caseId];
                  
            system.debug('--CaseInfo--'+CaseInfo);
}
}
   public pagereference backUrl()
    {
        pagereference pg=new pagereference('/apex/page10');
        return pg;
    }
}

 

Hi Guys,
Need your help on the below situation.
I have a page which is showing "List of Cases" for my organisation.I have added few filter fileds like date range ,staus etc so that I can refine the case list based on my requirement.If I click on any case from the list it should redirect to case detail page and in case detail page I have a "back" command link which will take us to orginal "List of Cases"page on clicking.
Now the requirement is if I apply case filter data range as yesterday's date to today's date and it retuns 1 case, after clciking on that case it should redirect to the case detail page as mentioned before and after clicking the back command link in case detail page it should redirect back to refined serach result (it should show that 1 case in the list not all the cases) not to the original "List of Cases".please note thst url is not changing when applying the case filters in "List of Cases" page.
Thanks for your help in advance.
Ok, so in a process builder i have to create a new criteria that checks if the Case owner has changed (which i have this part) but also that the owner is not a Queue that part i'm stuck on

can anyone help?
I have built a trigger that should fire when an Opportunity is created or updated in a particular way.

I was so focused on the update part that I never tested the on insert part until today.

Everything else in trigger works but I can't figure out why it does not execute when the Opp is first created.

Here is the complete trigger:
trigger createOqNew on Opportunity (after insert, after update) 

//trigger
{ 
   
    // try
    try{
           
        Id recordTypeId =
        Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('CDARS_ICS_Prospect').getRecordTypeId();
        
        List <Open_Quarter__c> createOpenQuarter = new List <Open_Quarter__c>();
        List <Open_Quarter__c> deleteOpenQuarter = new List <Open_Quarter__c>();
        
        // for loop 1
        for (Opportunity opportunityList : Trigger.new) {   
            
            // if loop 1
            if (opportunityList.RecordTypeId == recordTypeId) {
                
                // if loop 2
                if (Trigger.isInsert 
                    || (Trigger.isUpdate && opportunityList.Estimated_Start_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Start_Quarter__c)
                    || (Trigger.isUpdate && opportunityList.Estimated_Finish_Quarter__c != Trigger.oldMap.get(opportunityList.Id).Estimated_Finish_Quarter__c)){
                                          
                    Decimal year = opportunityList.Start_Year__c;
                    Decimal quarter = opportunityList.Start_Quarter__c;
                    Decimal span = opportunityList.Quarters_Spanned_op__c;
                    
                    //for loop 2
                    for (Integer counter = 0; counter < span; counter++)
                    {
                        Open_Quarter__c oq           = new Open_Quarter__C();
                        oq.Amount_Per_Quarter_oq__c  = opportunityList.Amount_per_Quarter_op__c;
                        oq.Close_Date_oq__c          = opportunityList.CloseDate;
                        oq.Name                      = year+'-'+'Q'+quarter;
                        oq.Opportunity_Name_oq__c    = opportunityList.Id;
                        
                        createOpenQuarter.add(oq);
                        quarter++;
                        
                        // if loop 3
                        if (quarter > 4) {
                            quarter = 1;
                            year++;
                        } //end if loop 3                       
                    } //end for loop 2      
                } //end if loop 2
            } //end if loop 1
        } //end for loop 1
        deleteOpenQuarter.addAll ([SELECT Id, Name FROM Open_Quarter__c WHERE Opportunity_Name_oq__c IN :trigger.newMap.keySet()]);
        
        // if loop 4
        if (deleteOpenQuarter.isEmpty()==false){
            Database.delete (deleteOpenQuarter,false);
        } // end if loop 4
        
        // if loop 5
        if(createOpenQuarter.isEmpty()==false){
            Database.insert (createOpenQuarter,false);
        } // end if loop 5
    } // end try
    
    //catch
    catch (Exception e){
        //e.getMessage()
            //e.getLineNumber()
            throw e;
    } // end catch
} // end trigger
It seems like it should work on insert but it does not. It only works on update.

Any suggestions?

Steve
 
Hi All,

I was referring the salesforce documentation for lightning:input type="email" .There it is mentioned When multiple email is used, the email field expects a single email address or a comma-separated list of email addresses. Example, my@domain.com,your@domain.com with or without a space after the comma.Is it possible to use type="email" when there is a need to enter multiple email id.I have tried to enter multiple emails with comma separation but it is giving me error as "You have entered an invalid format.".
I have a parent object and child object, in which a parent record shouldn't have duplicate child records.the following trigger is working fine but it is checking only the records in the database.

But my issue is? user is inserting two duplicate records at a time using .csv file and since my trigger is only validating the records in the database.
hence these duplicate records are also getting inserted.

How can I check duplicate in the .csv file itself ? or how to overcome this issue.

Can any one help me on this.
Trigger:
trigger BeatNameDuplicateCheck on Beat_TSE_Mapping__c (before insert, before update) {
        set<Id>TSEID= new set<ID>();
        set<string>bitname=new set<string>();
        map<string,Beat_TSE_Mapping__c> bitmap= new map<string,Beat_TSE_Mapping__c> ();
               for(Beat_TSE_Mapping__c beat:Trigger.new)
        {
            TSEID.add(beat.TSE_Code__c);
            bitname.add(beat.Beat_Name__c); 
        }
        if (!TSEID.isEmpty() ){
             List<Beat_TSE_Mapping__c> TSElist=new List<Beat_TSE_Mapping__c>();
        TSElist=[select id,Beat_Name__c,TSE_Code__c from Beat_TSE_Mapping__c where Beat_Name__c In: bitname and TSE_Code__c In: TSEID];
                       
        if (TSElist.size()>0) {
            for(Beat_TSE_Mapping__c beat:TSElist)
            {
              bitmap.put(beat.Beat_Name__c, beat);
            }     
        } 
                  }
        for (Beat_TSE_Mapping__c beat:Trigger.new)
                    {
            If (bitmap.containsKey(beat.Beat_Name__c ))
            {
                beat.Beat_Name__c.AddError('Beat Name Already Exist. Please try with another BeatName. ');
           }
        } 
}
Hi ,

On VF page , we are giving the below condition for required attribute ,
<apex:inputField value="{!cr.Contact.DOB__c}" label="Date of Birth" required="{!IF(cr.Contact.Primary_Officer_Percent__c >= 25, true, false)}"  >

but when the page is loaded we get the below error,

The value 'null' is not valid for operator '>='
Error is in expression '{!IF(cr.Contact.Primary_Officer_Percent__c >= null, true, false)}' in component <apex:inputField> in page jhcustomform


is it because cr.Contact.Primary_Officer_Percent__c is null when the page is loaded ? If yes is there any other way to do this ?

Thanks
  • July 11, 2018
  • Like
  • 0
Hi,
I have created a Visualforce Page titled NewActionListView.vfp. The code is listed below:
<apex:page controller="NewActionListController">
     <apex:pageblock title="User Actions List" id="actions_list"> 
        <apex:repeat var="act" value="{! newActions }" rendered="true"  id="action_list"  >
            <li>
                <apex:outputLink value="/{!act.ID}" >
                    <apex:outputText value="{! act.Name}"/>
                </apex:outputLink>
            </li>
        </apex:repeat>        
    </apex:pageblock>
</apex:page>

The controller - NewActionListController.apxc referenced is listed below:
public class NewActionListController {
    
public List<ACT_Action__c> getnewActions() { 
        List<ACT_Action__c> results = Database.query(
        'SELECT ID, Name FROM ACT_Action__c');
    return results;
}
}

It creates a simple listing from a custom object ACT_Action__c. 

I am trying to insert it into my Lightning App ACT Tracker. However, when I go to add a Visualforce Page, I don't see the NewActionListView page listed. Is there something else that I need to add to my code?
Thanks!
 
Hi,

I am new to salesforce. Got to know that some recent changes happened in salesforce lightning .

Earlier the below code was working fine with salesforce in custom visual force page to get the record ID value from URL:
 
 retURL=ApexPages.currentPage().getParameters().get('retURL')
idURL  = Id.valueOf(retURL.removeStart('/'));

Now when I try to create any record ,the below error is shown:

Invalid id: lightning/cb/record-actions?objectApiName=Object_Name__c&actionName=new&inContextOfRef=1.eyJ0eXBlIjoic3RhbmRhcmRfX29iamVjdFBhZ2UiLCJhdHRyaWJ1dGVzIjp7Im9iamVjdEFwaU5hbWUiOiJDU1RfQ29udGFjdF9Sb2xlX19jIiwiYWN0aW9uTmFtZSI6Imxpc3QifSwic3RhdGUiOnsiZmlsdGVyTmFtZSI6IlJlY2VudCJ9fQ%3D%3D&0.source=alohaHeader

Could some one please check and suggest the way forward.

Thaanks & Regards,
Bsin
  • July 11, 2018
  • Like
  • 0
Hi ,
Is there anyone worked on UserRole object before.I have a requiremnt where I have to change the ParentRole for the partner users role,What I understood we can do this with userRole object but the problem is it is not allowing me to update the parentRole Id field for the  UserRole objecteven though in field description section it is showing up dateable.Anyone anybidea how that can be done? or any other suggestion?


User-added image
Hi All,

How to remove muliple occurences from a string?say for example if we give input as 'MISSISSIPPI' .I need to get output as 'MISP'.

can anyone please help on this.

Thanks,
Sirisha
I have created a visualforce page but when you click on the page section it is defaulted to edit mode, i want it to behave similar to classis in the way that its in read mode until you click an edit button.... here is the starting code of my page

<apex:page standardController="opportunity" lightningStylesheets="true">
 <apex:messages />

    <apex:form >
        <apex:pageBlock title="" mode="edit">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
Field                API Name          Datatype
Contact           Contact__c         LookUp        //field from Opportunity
Awesome        Awesome__C    CheckBox    //field from Contact
global class BatchAwesomeContact implements Database.Batchable<sObject>{
    Map<Id, Contact> conts = new Map<Id, Contact>();
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String Query = 'SELECT Id, Contact__c, Amount, (SELECT Id, FirstName, LastName, Awesome__c FROM Contact) FROM Opportunity WHERE Id IN :conts.keySet()';
        return Database.getQueryLocator(Query);
    }
    
    global void execute(Database.BatchableContext BC, List<Opportunity> scope) {
        for (Opportunity s : scope) {
            if (s.Contact__c != null) {
                if (s.Amount >= 500 && !conts.containsKey(s.Contact__c)) {
                    conts.put(s.Contact__c, new Contact(Id = s.Contact__c, Awesome__c = true));
                }
            }
        }
        update conts.values();
    }
    
    global void finish(Database.BatchableContext BC) {
        
    }
}
Hi Guys,

I have created a pageblock table where user can dynmically add and remove rows .In each rows I am using an input field .The problem I am facing while clicking the add row button its resetting the previous value entered in the previous row.Kindly help if anyone else faced the same problem .
<apex:page standardController="Account" extensions="AddnRemoveController" >
<apex:form id="f" >
<apex:pageMessages ></apex:pageMessages>
<div>
 <apex:pageBlock mode="maindetail" >
 <!-- <apex:variable value="{!0}" var="rowNumber" /> -->
  <apex:commandButton value="AddRow" action="{!addrow}" reRender="table">
  </apex:commandButton>
  <apex:commandButton value="Remove Row" action="{!removerow}" reRender="table">
  <!-- <apex:param value="" name="rowNum" assignTo="{!rowNum}" /> -->
  </apex:commandButton>
  
 
  <apex:pageBlockTable value="{!wrapList}" var="wrapVar" id="table">
  <!-- <apex:variable value="{!wrapVar.index}" var="rowNumber" /> -->
   <apex:column >{!wrapVar.index}</apex:column>
   <apex:column headervalue="{!wrapVar.act.Industry}">
    <apex:inputField value="{!wrapVar.act.Industry}" id="modalBankCountry"/>
   </apex:column>
  </apex:pageBlockTable>
   <apex:commandButton value="Save" action="{!saving}" />
 </apex:pageBlock>
 </div>
 </apex:form>
</apex:page>
 
<apex:page standardController="Account" extensions="AddnRemoveController" >
<apex:form id="f" >
<apex:pageMessages ></apex:pageMessages>
<div>
 <apex:pageBlock mode="maindetail" >
 <!-- <apex:variable value="{!0}" var="rowNumber" /> -->
  <apex:commandButton value="AddRow" action="{!addrow}" reRender="table">
  </apex:commandButton>
  <apex:commandButton value="Remove Row" action="{!removerow}" reRender="table">
  <!-- <apex:param value="" name="rowNum" assignTo="{!rowNum}" /> -->
  </apex:commandButton>
  
 
  <apex:pageBlockTable value="{!wrapList}" var="wrapVar" id="table">
  <!-- <apex:variable value="{!wrapVar.index}" var="rowNumber" /> -->
   <apex:column >{!wrapVar.index}</apex:column>
   <apex:column headervalue="{!wrapVar.act.Industry}">
    <apex:inputField value="{!wrapVar.act.Industry}" id="modalBankCountry"/>
   </apex:column>
  </apex:pageBlockTable>
   <apex:commandButton value="Save" action="{!saving}" />
 </apex:pageBlock>
 </div>
 </apex:form>
</apex:page>

 
Hi,

I have a multi select picklist field on vf page. I am rendering text field based on the value in multi picklist. Now i want to render other picklist field based on multipicklist value(with different condition). Since Iam already rendering one field i have written onchange event. now i cant use the same event and write another event for the same tag. How can I render two fields onchange of first field(two fields should be rendered with two conditions)? Please help me to achieve this scenario.

Thanks. 
  • December 13, 2017
  • Like
  • 0
I am in the last action where the process builder calls the invocable apex class. When i look for the class it appears with the LabelName
 'Give a Thanks Badge' and the lookups do not show up on the Giver Id and Receiver Id fields. Can someone tell me what am I doing wrong?
User-added image
If i put the apex class name as is shown in the trail it still does not find the Giver Id and Receiver Id values. My apex code has an active status.
User-added image
Thank you.