• 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
 
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
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
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. 
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.