-
ChatterFeed
-
25Best Answers
-
0Likes Received
-
1Likes Given
-
10Questions
-
127Replies
In process builder how to create a new criteria that checks if the Case owner has changed and also that the owner is not a Queue
can anyone help?
- Carolyn Carolyn
- April 18, 2020
- Like
- 0
- Continue reading or reply
I need a little help with a trigger please
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 triggerIt seems like it should work on insert but it does not. It only works on update.
Any suggestions?
Steve
- Steve Connelly 5
- April 17, 2020
- Like
- 0
- Continue reading or reply
Trigger to avoid duplicate records when ever user trying to insert records using Dataloader
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. ');
}
}
}
- ranga babu vangalapudi 2
- July 11, 2018
- Like
- 0
- Continue reading or reply
I want to render two fields based on change in single field with different conditions
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.
- Chubby
- December 13, 2017
- Like
- 0
- Continue reading or reply
Display alert with visual force page when two picklist fields are null
<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
- Nina Gonzalez
- July 10, 2017
- Like
- 0
- Continue reading or reply
hide rows in Apex:column
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
Regards
Chiel
- Chiel de Graaf.
- May 31, 2017
- Like
- 0
- Continue reading or reply
Why am I getting this error ?Please look at the Attachment and Description
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"
- Kiran Pandiyan
- May 25, 2017
- Like
- 0
- Continue reading or reply
Trigger on Quote line item
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?
- Shunn
- May 04, 2017
- Like
- 0
- Continue reading or reply
Cancel Button ask to fill required fields. How Can i Overcome this.
Here My code
Apex:
Public Pagereference docancel(){
PageReference pageRef = new PageReference('/001/o');
pageRef.setRedirect(true);
return pageRef;
}
- Manikandan C 14
- April 20, 2017
- Like
- 0
- Continue reading or reply
Hyperlink action
Thanks in advance
Sumanth Kumar
- sumanth kumar 26
- April 07, 2017
- Like
- 0
- Continue reading or reply
userInfo.getusername() not returning expected value
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
- Carlos Labastida
- April 06, 2017
- Like
- 0
- Continue reading or reply
how to show a pageBlock using outputLink value
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!!!
- miko Lee
- April 06, 2017
- Like
- 0
- Continue reading or reply
Code coverage issue for triggerhandler
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
- sonam guptha
- April 05, 2017
- Like
- 0
- Continue reading or reply
Test Class on Event Trigger
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'); } } }
- Priya134
- April 04, 2017
- Like
- 0
- Continue reading or reply
How show in the visualpage the value of an variable?
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>
- Rafael.Martins.Santos
- April 04, 2017
- Like
- 0
- Continue reading or reply
In need to display records on visualforce page according to picklist value selected in the dropdown using custom controller.
- Girish Goswami 16
- March 31, 2017
- Like
- 0
- Continue reading or reply
want test class for trigger
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; } }
- Akash Garg 2
- March 30, 2017
- Like
- 0
- Continue reading or reply
where i need a pick list on my VF page , picklist 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
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
- satish yagana 4
- March 29, 2017
- Like
- 0
- Continue reading or reply
Hi! I was able to create my first Event trigger to update an opportunity field but am having problems creating a test class. Any assistance is appreciated!
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);
}
}
- Monet Zamaripa 3
- March 28, 2017
- Like
- 0
- Continue reading or reply
is salesforce automatically change the owner of contact when its parents account owner is changed ?
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
- Subodh Shukla 16
- March 22, 2017
- Like
- 0
- Continue reading or reply
Salesforce flow error : {flowruntime:lwcBody}
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?
- DeveloperSud
- September 03, 2022
- Like
- 0
- Continue reading or reply
How to inherit css styles in child component from parent in LWC?
- DeveloperSud
- June 11, 2021
- Like
- 0
- Continue reading or reply
The Create New option for lookups is viable in Customer Service communities but this is mentioned as limitation in lightning community guide.Need clarification.
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.
- DeveloperSud
- October 11, 2020
- Like
- 0
- Continue reading or reply
Is it possible to use lightning:input type="email" for mutiple email address?
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.".
- DeveloperSud
- April 07, 2020
- Like
- 0
- Continue reading or reply
Which all authentication can be maintain when a third party application make a SOAP callout in salesforce?
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?
- DeveloperSud
- September 04, 2019
- Like
- 0
- Continue reading or reply
Not able to update parentRole for UserRole object using apex code
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?
- DeveloperSud
- June 13, 2018
- Like
- 0
- Continue reading or reply
Dynamic Add row button in pageBlockTable without Resetting the entered input values in each row while clicking add row button
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>
- DeveloperSud
- January 04, 2018
- Like
- 0
- Continue reading or reply
How to create two mutually dependent custom picklist in visualforce ?
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; } }
- DeveloperSud
- January 16, 2017
- Like
- 0
- Continue reading or reply
Visualforce Page: Redirect back to search result after clicking 'Back To Cases' link.
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; } }
- DeveloperSud
- August 01, 2016
- Like
- 0
- Continue reading or reply
Urgent Help: Redirect back to search result after clicking 'Back'
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.
- DeveloperSud
- July 25, 2016
- Like
- 0
- Continue reading or reply
In process builder how to create a new criteria that checks if the Case owner has changed and also that the owner is not a Queue
can anyone help?
- Carolyn Carolyn
- April 18, 2020
- Like
- 0
- Continue reading or reply
I need a little help with a trigger please
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 triggerIt seems like it should work on insert but it does not. It only works on update.
Any suggestions?
Steve
- Steve Connelly 5
- April 17, 2020
- Like
- 0
- Continue reading or reply
Is it possible to use lightning:input type="email" for mutiple email address?
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.".
- DeveloperSud
- April 07, 2020
- Like
- 0
- Continue reading or reply
Trigger to avoid duplicate records when ever user trying to insert records using Dataloader
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. ');
}
}
}
- ranga babu vangalapudi 2
- July 11, 2018
- Like
- 0
- Continue reading or reply
>= not working in VF Page
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
- Desai
- July 11, 2018
- Like
- 0
- Continue reading or reply
How do I include a visualforce page in my lightning app
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!
- Diane Roberts 3
- July 11, 2018
- Like
- 0
- Continue reading or reply
ApexPages.currentPage().getParameters().get()
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:
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
- Bsin
- July 11, 2018
- Like
- 0
- Continue reading or reply
Not able to update parentRole for UserRole object using apex code
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?
- DeveloperSud
- June 13, 2018
- Like
- 0
- Continue reading or reply
how to remove multiple occurences in a given string?
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
- SFDC New learner
- March 01, 2018
- Like
- 0
- Continue reading or reply
How do i change Visualforce page not to default to edit mode
<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>
- Karen Brown 39
- February 27, 2018
- Like
- 0
- Continue reading or reply
How to create test class of Batch class?
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) { } }
- ForceRookie
- February 27, 2018
- Like
- 0
- Continue reading or reply
Dynamic Add row button in pageBlockTable without Resetting the entered input values in each row while clicking add row button
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>
- DeveloperSud
- January 04, 2018
- Like
- 0
- Continue reading or reply
I want to render two fields based on change in single field with different conditions
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.
- Chubby
- December 13, 2017
- Like
- 0
- Continue reading or reply
Automate Post-Workshop Tasks with Invocable Apex
'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?
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.
Thank you.
- alo sen 12
- February 03, 2017
- Like
- 0
- Continue reading or reply
- Jyotika Jain 7
- July 23, 2015
- Like
- 1
- Continue reading or reply