-
ChatterFeed
-
8Best Answers
-
0Likes Received
-
1Likes Given
-
0Questions
-
78Replies
How to pass the id from visualforce page when i click the preview button
When i click on the preview button the id of the associated record id should get passed to the controller. Its urgent
- Amit Visapurkar 5
- June 15, 2016
- Like
- 0
- Continue reading or reply
Multiple Objects in Pageblock table using Wrapper class: Error: tt Compile Error: Illegal assignment from List<Account> to List<RNK.account> at line 9 column 9
<apex:page controller="tt">
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapper}" var="wrap">
<apex:column headerValue="Account Name" value="{!wrap.accRec.Name}"/>
<!-- you can add related fields here -->
<apex:column headerValue="Contact Name" value="{!wrap.conRec.Name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Controller:
public class tt
{
public List<Account> accLst {get; set;}
public List<Contact> conLst {get; set;}
public List<MyWrapper> wrapper {get; set;}
public tt()
{
accLst = [select id,name from account ] ;
conLst = [select id,name from contact ] ;
wrapper = new List<MyWrapper>() ;
for(Integer i=0 ;i<20;i++)
wrapper.add(new MyWrapper(accLst[i] , conLst[i])) ;
}
public class MyWrapper
{
public Account accRec {get; set;}
public Contact conRec {get; set;}
public MyWrapper(Account acc , Contact con)
{
accRec = acc ;
conRec = con ;
}
}
}
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapper}" var="wrap">
<apex:column headerValue="Account Name" value="{!wrap.accRec.Name}"/>
<!-- you can add related fields here -->
<apex:column headerValue="Contact Name" value="{!wrap.conRec.Name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Controller:
public class tt
{
public List<Account> accLst {get; set;}
public List<Contact> conLst {get; set;}
public List<MyWrapper> wrapper {get; set;}
public tt()
{
accLst = [select id,name from account ] ;
conLst = [select id,name from contact ] ;
wrapper = new List<MyWrapper>() ;
for(Integer i=0 ;i<20;i++)
wrapper.add(new MyWrapper(accLst[i] , conLst[i])) ;
}
public class MyWrapper
{
public Account accRec {get; set;}
public Contact conRec {get; set;}
public MyWrapper(Account acc , Contact con)
{
accRec = acc ;
conRec = con ;
}
}
}
- admin 7
- June 15, 2016
- Like
- 0
- Continue reading or reply
Creating FAQs
Hi,
I am new to Salesforce and it would be great, if community can give me some idea to create FAQs. Do I have to treat FAQ as knowledge article and proceed to create custom object for the same?
I am new to Salesforce and it would be great, if community can give me some idea to create FAQs. Do I have to treat FAQ as knowledge article and proceed to create custom object for the same?
- Sourav Sengupta 8
- June 15, 2016
- Like
- 0
- Continue reading or reply
How to convert JSON string to required JSON string?
Hi ,
I'm trying to parse Account records to JSON string. But I'm getting unnecessary data like attributes(type,url) that is not required in String.
Can any one pls help me in how to parse the string to required format.
My requirement is to generate resulting String as below JSON string format.
So that I can minimize the data to to be sent the the client system.
Any help is really appreciated. Thanks in advance.
Regards,
Naveen.
I'm trying to parse Account records to JSON string. But I'm getting unnecessary data like attributes(type,url) that is not required in String.
Can any one pls help me in how to parse the string to required format.
List<Account> accnts=[Select Name,Phone From Account]; String s=JSON.serialize(accnts);The resulting output is in below fromat..
{ "attributes" : { "type" : "Account", "url" : "/services/data/v34.0/sobjects/Account/00128000002trGGAAY" }, "Name" : "GenePoint", "Phone" : "(650) 867-3450", "Id" : "00128000002trGGAAY" }
My requirement is to generate resulting String as below JSON string format.
{ "Name" : "GenePoint", "Phone" : "(650) 867-3450", "Id" : "00128000002trGGAAY" }
So that I can minimize the data to to be sent the the client system.
Any help is really appreciated. Thanks in advance.
Regards,
Naveen.
- naveen reddy 19
- July 17, 2015
- Like
- 1
- Continue reading or reply
Refresh VF Page after method executes
Hi,
I need to refresh the whole VF Page once my delete method executes. I have wriiten the below code. When I delete a particular record, the record is getting deleted but the page is not refreshing to show the updated records. Please help.
VF Page:
<apex:page controller="viewdept_con" showHeader="false " id="mypage">
<apex:form >
<apex:pageBlock >
<apex:pageblockTable value="{!deptlist}" var="item">
<apex:column headerValue="Action">
<apex:commandLink value="Detail" action="{!deptdetail}"/><b> | </b>
<apex:commandLink value="Del" action="{!deptdelete}" reRender="mypage">
<apex:param name="deptid" value="{!item.id}" assignTo="{!deptid}"/>
</apex:commandlink>
</apex:column>
<apex:column value="{!item.name}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class viewdept_con {
public list<department__c> deptlist { get; set; }
public id deptid {get; set;}
public department__c dept {get; set;}
public viewdept_con()
{
deptlist = [select id, name from department__c];
}
public pagereference deptdetail()
{
pagereference pg = new pagereference('/apex/DepartmentDetail?deptid=' + deptid);
return pg;
}
public pagereference deptdelete()
{
dept = [select id, name from department__c where id = :deptid];
delete dept;
return null;
}
}
Thank you,
Satya
I need to refresh the whole VF Page once my delete method executes. I have wriiten the below code. When I delete a particular record, the record is getting deleted but the page is not refreshing to show the updated records. Please help.
VF Page:
<apex:page controller="viewdept_con" showHeader="false " id="mypage">
<apex:form >
<apex:pageBlock >
<apex:pageblockTable value="{!deptlist}" var="item">
<apex:column headerValue="Action">
<apex:commandLink value="Detail" action="{!deptdetail}"/><b> | </b>
<apex:commandLink value="Del" action="{!deptdelete}" reRender="mypage">
<apex:param name="deptid" value="{!item.id}" assignTo="{!deptid}"/>
</apex:commandlink>
</apex:column>
<apex:column value="{!item.name}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class viewdept_con {
public list<department__c> deptlist { get; set; }
public id deptid {get; set;}
public department__c dept {get; set;}
public viewdept_con()
{
deptlist = [select id, name from department__c];
}
public pagereference deptdetail()
{
pagereference pg = new pagereference('/apex/DepartmentDetail?deptid=' + deptid);
return pg;
}
public pagereference deptdelete()
{
dept = [select id, name from department__c where id = :deptid];
delete dept;
return null;
}
}
Thank you,
Satya
- Satya413
- July 14, 2015
- Like
- 0
- Continue reading or reply
Not getting value for first record using trigger
This is my requirement
Create auto number field in the object: npe03_Recurring_Donation. This field will have the property that it will reset every month. This field will be unique according to another field: DSYDonationType_c.
Meaning if DSYDonationType_c='cheque' , the auto number field will start from chq-1,chq-2,chq-3...so on...on 1 st of every month and reset on 1 st of next month. If DSYDonationType_c='Online', auto number will start from onl-1,onl-2,onl-3 ...and so on.
I am working on the below code
It is working fine but the when the first record is created, it will not fetch any value in the field Reset number, from next record onwards it will start incrementing, but I don't want the first record to be empty because of which I need to enter the value manually, can some one help me on this...
Below is my code
Create auto number field in the object: npe03_Recurring_Donation. This field will have the property that it will reset every month. This field will be unique according to another field: DSYDonationType_c.
Meaning if DSYDonationType_c='cheque' , the auto number field will start from chq-1,chq-2,chq-3...so on...on 1 st of every month and reset on 1 st of next month. If DSYDonationType_c='Online', auto number will start from onl-1,onl-2,onl-3 ...and so on.
I am working on the below code
It is working fine but the when the first record is created, it will not fetch any value in the field Reset number, from next record onwards it will start incrementing, but I don't want the first record to be empty because of which I need to enter the value manually, can some one help me on this...
Below is my code
trigger Reset_restart_autonum on npe03__Recurring_Donation__c (before insert) { Public integer i; Public integer month1; List<npe03__Recurring_Donation__c> hold=New list<npe03__Recurring_Donation__c>(); String st2; Public Date todaysDate = system.today(); Integer month = todaysDate.month(); //Integer month=9; month1=month+1; hold=[Select id,createddate,DSYDonationType__c,Reset_number__c from npe03__Recurring_Donation__c where DSYDonationType__c=:trigger.new[0].DSYDonationType__c order by CreatedDate DESC LIMIT 1]; for(npe03__Recurring_Donation__c Adding:Hold){ String st = Adding.Reset_number__c; system.debug('========Reset=========='+Adding.Reset_number__c); if(st== null){ st = 'DD-000'; } system.debug('========ST=========='+ST); i = Integer.valueOf(st.split('-')[1]); i++; system.debug('========Increment=========='+i); If(Adding.DSYDonationType__c!=Null && month== Adding.createddate.month() ){ if(String.ValueOf(i).length() == 3){ /*Do Nothing*/ }else if(String.ValueOf(i).length() == 2){ st2 = 'DD-0'+String.valueOf(i); system.debug('========ST=========='+ST2); }else if(String.ValueOf(i).length() == 1){ st2 = Adding.DSYDonationType__c+'-00'+String.valueOf(i); system.debug('========ST=========='+ST2); } Adding.Reset_number__c= st2; system.debug('========ST=========='+ST2); }Else if((month!= Adding.createddate.month()) || (month==month1) ){ st2='DD-000'; Adding.Reset_number__c=st2; system.debug('========Cash-000=========='+Adding.Reset_number__c); } } Trigger.New[0].Reset_number__c=St2; }
- manjunath vivek
- July 14, 2015
- Like
- 0
- Continue reading or reply
SOQL query returning something when it shouldn't
Hello all,
I have a list of accounts for which I am the product owner. I modified them all today for testing purposes, in order to have my custom field Last_Update__c = today.
In my VF page, I call my custom constructor which does something very simple (please note that I removed the code handling the exceptions for brevity reasons
public Account getAccount() { account = [SELECT Id, Name, Last_Status__c,Additional_Information__c,Ongoing_Problem__c,Last_Update__c FROM Account WHERE (OwnerId = :UserInfo.getUserID()) AND (Type <> 'Dead') AND (Last_Update__c = LAST_N_DAYS:150) ORDER BY Last_Update__c LIMIT 1]; return account; }
The idea should be to retrieve an account only when three conditions are all met. Third one is
Last_Update__c = LAST_N_DAYS:150. In my understanding, this should mean: "select an account if Last Update was done more than 150 days ago". However, I get every account in the list as a result, even if they all have today as last_update__c field. What am I doing wrong?
Thanks in advance for your help on this.
Cheers, A.
- Andreas Wissmeyer
- July 10, 2015
- Like
- 0
- Continue reading or reply
Test class apex help needed
Hi,
I have a apex class for which i have a test class which covers 57% right now , i need help to cover certain methods which i am not able to cover
Kindly help me on this regard
Method need to cover
public boolean getteamFormStatus() {
boolean blStatus = false;
System.debug('TeamFormparaId:'+paraId);
gpsquoteobj = [select GPSTeamForm__r.Status__c,GPSTeamForm__r.Engagement_Script__c,GPSTeamForm__r.Engagement_Team__c,Quote_Status__c,Quote_Comments__c,LastModifiedBy.name,LastModifiedDate,Name,PremiSys_Quote_Id__c,GPSTeamForm__c,Quote_Version__c,CreatedDate,GPSTeamForm__r.Name from GPS_PremiSys_Quote__c
where id =:paraId order by CreatedDate desc];
if(gpsquoteobj.GPSTeamForm__r.Status__c == 'Won')
{
blStatus = true;
return blStatus;
}
return blStatus;
}
MY TEST CLASS :
When i write objinstance.methodname() dirctly i am getting list has no rows error
Kindly help me pls
Thanks in Advance
I have a apex class for which i have a test class which covers 57% right now , i need help to cover certain methods which i am not able to cover
Kindly help me on this regard
Method need to cover
public boolean getteamFormStatus() {
boolean blStatus = false;
System.debug('TeamFormparaId:'+paraId);
gpsquoteobj = [select GPSTeamForm__r.Status__c,GPSTeamForm__r.Engagement_Script__c,GPSTeamForm__r.Engagement_Team__c,Quote_Status__c,Quote_Comments__c,LastModifiedBy.name,LastModifiedDate,Name,PremiSys_Quote_Id__c,GPSTeamForm__c,Quote_Version__c,CreatedDate,GPSTeamForm__r.Name from GPS_PremiSys_Quote__c
where id =:paraId order by CreatedDate desc];
if(gpsquoteobj.GPSTeamForm__r.Status__c == 'Won')
{
blStatus = true;
return blStatus;
}
return blStatus;
}
MY TEST CLASS :
@isTest(seeallData = true) public class GpsPremiSysQuoteRLController_test { static testmethod void GpsPremiSysQuoteRLTestMethod(){ string strUsr; User usr = GPSTestUtilities.createStandardUser(strUsr); System.runAs(usr){ Account acct = GPSTestUtilities.createTestAccount(); Pricebook2 pb = GPSTestUtilities.getTestPriceBook(); product2 pr = GPSTestUtilities.createproduct(); test.startTest(); Product_Designator__c pd = GPSTestUtilities.createprodDesignator(); Opportunity op = GPSTestUtilities.createTestOpportunity(acct.Id); OpportunityLineItem opline = GPSTestUtilities.createTestOpportunityLineItem(op.Id); //list<OpportunityLineItem>lstopplt = [select ]; GPS_PRx__c prx = GPSTestUtilities.createGPSPRX(pd.Id); test.stopTest(); system.debug('OpptyID=>'+op.Id); Engagement_Script__c EP = GPSTestUtilities.createEngagementScript(acct.Id,op.Id); system.debug('EP=>'+EP); Team_Form__c TF = GPSTestUtilities.createTeamForm(EP.Id); GPS_TF_Product_Line_Item__c prlitem = GPSTestUtilities.createGPSLineitms(prx.Id, EP.Id, TF.Id); GPS_PremiSys_Quote__c Quote = GPSTestUtilities.createPremisysQuote(EP.Id, TF.Id); //set up GPS Premisys Quote GPS_PremiSys_Quote__c sdquote = new GPS_PremiSys_Quote__c(); sdquote.Quote_Status__c='New'; sdquote.GPSTeamForm__c =TF.Id; sdquote.Engagement_Script_Id__c=EP.Id; sdquote.Quote_Comments__c='Test'; insert sdquote; ApexPages.currentPage().getParameters().put('id', TF.Id); // Apexpages.StandardController sc = new Apexpages.StandardController (TF); GpsPremiSysQuoteRLController objquoteRLcon = new GpsPremiSysQuoteRLController(); // objquoteRLcon.getGpsPremiSysQuoteList(); objquoteRLcon.Custsave(); } } static testmethod void GpsPremiSysQuoteRLTestMethodNoES(){ string strUsr; User usr = GPSTestUtilities.createStandardUser(strUsr); System.runAs(usr){ Account acct = GPSTestUtilities.createTestAccount(); Pricebook2 pb = GPSTestUtilities.getTestPriceBook(); product2 pr = GPSTestUtilities.createproduct(); Product_Designator__c pd = GPSTestUtilities.createprodDesignator(); Opportunity op = GPSTestUtilities.createTestOpportunity(acct.Id); test.startTest(); OpportunityLineItem opline = GPSTestUtilities.createTestOpportunityLineItem(op.Id); //list<OpportunityLineItem>lstopplt = [select ]; GPS_PRx__c prx = GPSTestUtilities.createGPSPRX(pd.Id); system.debug('OpptyID=>'+op.Id); Engagement_Script__c EP = GPSTestUtilities.createEngagementScript(acct.Id,op.Id); system.debug('EP=>'+EP); Team_Form__c TF = GPSTestUtilities.createTeamForm(EP.Id); GPS_TF_Product_Line_Item__c prlitem = GPSTestUtilities.createGPSLineitms(prx.Id, EP.Id, TF.Id); //GPS_PremiSys_Quote__c Quote = GPSTestUtilities.createPremisysQuote(EP.Id, TF.Id); test.stopTest(); ApexPages.currentPage().getParameters().put('id', TF.Id); //Apexpages.StandardController sc = new Apexpages.StandardController (TF); GpsPremiSysQuoteRLController objquoteRLcon = new GpsPremiSysQuoteRLController(); // objquoteRLcon.getGpsPremiSysQuoteList(); objquoteRLcon.getteamFormStatus =true; } } }
When i write objinstance.methodname() dirctly i am getting list has no rows error
Kindly help me pls
Thanks in Advance
- sfdc007
- July 09, 2015
- Like
- 0
- Continue reading or reply
Uploading a logo through visualforce page
I am doing a task where i want to store a logo on a visualforce page. in this i can choose one of the image from storage space and will display it as a logo. While doing this task we need to keep in mind that we can't directly display image in visualforce page in salesforce. It should be stored at some place like in document folder in our salesforce organization. i am stuck with this code i am getting error at this line in visualforce page <apex:inputFile value="{!Document.body}" filename="{!Document.name}" /> . here i m getting error in String.name.. plz help me to solve this
public class showimage {
public String document { get; set; }
public showimage() {
}
public boolean showimage{set;get;}
public final document t;
private ApexPages.StandardController stdcontroller;
public showimage(ApexPages.StandardController stdcontroller) {
t = (Document) stdcontroller.getRecord();
t.folderid = UserInfo.getUserId(); //this saves record in My Personal Documents
this.stdcontroller=stdcontroller;
}
public pagereference save(){
this.stdcontroller.save();// this method implements the standard save method.
pagereference pg=new pagereference('/apex/vfpageimageupload');
showimage=true;
return pg;
}
List<document> d;
public id doc{set;}
public id getdoc()
{
d=[select id from document order by id desc limit 1]; //gets id of document inserted last in sobject
return d[0].id;// returns id value of list d
}
}
VF page:
<apex:page controller="showimage">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection title="Upload Photo" collapsible="false" columns="1" >
<apex:image url="https://c.ap1.content.force.com/servlet/servlet.FileDownload?file={!doc}" height="100"
width="100" rendered="{!showimage}" /> /*contains the url of documents,{!doc} gives the image dynamically */
<apex:inputFile value="{!Document.body}" filename="{!Document.name}" />
<center><apex:commandButton value="Upload" action="{!save}" /></center>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class showimage {
public String document { get; set; }
public showimage() {
}
public boolean showimage{set;get;}
public final document t;
private ApexPages.StandardController stdcontroller;
public showimage(ApexPages.StandardController stdcontroller) {
t = (Document) stdcontroller.getRecord();
t.folderid = UserInfo.getUserId(); //this saves record in My Personal Documents
this.stdcontroller=stdcontroller;
}
public pagereference save(){
this.stdcontroller.save();// this method implements the standard save method.
pagereference pg=new pagereference('/apex/vfpageimageupload');
showimage=true;
return pg;
}
List<document> d;
public id doc{set;}
public id getdoc()
{
d=[select id from document order by id desc limit 1]; //gets id of document inserted last in sobject
return d[0].id;// returns id value of list d
}
}
VF page:
<apex:page controller="showimage">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection title="Upload Photo" collapsible="false" columns="1" >
<apex:image url="https://c.ap1.content.force.com/servlet/servlet.FileDownload?file={!doc}" height="100"
width="100" rendered="{!showimage}" /> /*contains the url of documents,{!doc} gives the image dynamically */
<apex:inputFile value="{!Document.body}" filename="{!Document.name}" />
<center><apex:commandButton value="Upload" action="{!save}" /></center>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
- satakshi
- June 17, 2016
- Like
- 0
- Continue reading or reply
How to replicate the duplicate management rule in apex class
Hi
In Account object, therre is a duplicate management rule for account name. We override the edit page of account. The problem is when the user try to create a duplicate record it throwing the error like "Update failed. First exception on row 0 with id 001Q0000010c9osIAA; first error: DUPLICATES_DETECTED, You may be creating a duplicate record. If so, we recommend you use the existing record instead.: []
Error is in expression '{!CustomSave}' in component <apex:commandButton> in page customsavepage: Class.CustomControllerSaveofAccount.CustomSave: line 21, column 1".
But i wan to show like this
Can anyone help me out to solve this issue.
In Account object, therre is a duplicate management rule for account name. We override the edit page of account. The problem is when the user try to create a duplicate record it throwing the error like "Update failed. First exception on row 0 with id 001Q0000010c9osIAA; first error: DUPLICATES_DETECTED, You may be creating a duplicate record. If so, we recommend you use the existing record instead.: []
Error is in expression '{!CustomSave}' in component <apex:commandButton> in page customsavepage: Class.CustomControllerSaveofAccount.CustomSave: line 21, column 1".
But i wan to show like this
Can anyone help me out to solve this issue.
- shoba shoba
- June 17, 2016
- Like
- 0
- Continue reading or reply
Datetime
Can anyone tellme why this below changes happening. If i create a datetime instance with date 2016-06-16 and time 12:00 then the debug shows different datetime like i have mentioned below. Thanks in advance.
Datetime dTime1 = Datetime.newInstance(2016, 06, 16, 12, 00, 00); 2016-06-16 12:00:00
Datetime dTime2 = Datetime.newInstance(2016, 06, 16, 1, 00, 00); 2016-06-16 01:00:00
system.debug('dTime1 '+dTime1);
system.debug('dTime2 '+dTime2);
|DEBUG| dTime1 --> 2016-06-16 06:30:00
|DEBUG| dTime2 --> 2016-06-15 19:30:00
Datetime dTime1 = Datetime.newInstance(2016, 06, 16, 12, 00, 00); 2016-06-16 12:00:00
Datetime dTime2 = Datetime.newInstance(2016, 06, 16, 1, 00, 00); 2016-06-16 01:00:00
system.debug('dTime1 '+dTime1);
system.debug('dTime2 '+dTime2);
|DEBUG| dTime1 --> 2016-06-16 06:30:00
|DEBUG| dTime2 --> 2016-06-15 19:30:00
- NightFox
- June 16, 2016
- Like
- 0
- Continue reading or reply
Override Opportunity Product Multi-Line Layout with VF Page
Hi,
I need to override the "Opportunity Product Multi-Line Layout" page(Shown Below) with custom VisualForce Page.
For this I need to Add a new custom button(New Button) on the "Product Selection" page layout and Hide the existing Select Button on the Layout.
The Challenge is , I'm not getting from where to create a new Custom Button (New Button) to add on the Product Selection Page and how can I Hide the Existing Select Button from this page.
Or do I have to Override the "Product Selection" Page with a new Custom VF Page as well?
How Can I achieve this?
Any help on this would be appreciated.
Thanks,
Sagar
I need to override the "Opportunity Product Multi-Line Layout" page(Shown Below) with custom VisualForce Page.
For this I need to Add a new custom button(New Button) on the "Product Selection" page layout and Hide the existing Select Button on the Layout.
The Challenge is , I'm not getting from where to create a new Custom Button (New Button) to add on the Product Selection Page and how can I Hide the Existing Select Button from this page.
Or do I have to Override the "Product Selection" Page with a new Custom VF Page as well?
How Can I achieve this?
Any help on this would be appreciated.
Thanks,
Sagar
- Sagar Madkaikar
- June 16, 2016
- Like
- 0
- Continue reading or reply
SOQL with two IN in where clause with list as input
Hello All,
My query is ::
select id , name from account where name IN : NameList AND email IN : EmailList
Scenario ::
I am inserting data via dataloader with below details.
Name 1 xxx@yyy.com
Name 2 sss@rrr.com
Name 3 fff@uuu.com
I am trying to check in system on account object before insert whether any account record exists with the name and email combination.
Let me know whether two IN parameters as list in where clause will look for the data in the combination i gave ?
Ex :: Name 1 with only xxx@yyy.com and not with sss@rrr.com & fff@uuu.com
Thanks
My query is ::
select id , name from account where name IN : NameList AND email IN : EmailList
Scenario ::
I am inserting data via dataloader with below details.
Name 1 xxx@yyy.com
Name 2 sss@rrr.com
Name 3 fff@uuu.com
I am trying to check in system on account object before insert whether any account record exists with the name and email combination.
Let me know whether two IN parameters as list in where clause will look for the data in the combination i gave ?
Ex :: Name 1 with only xxx@yyy.com and not with sss@rrr.com & fff@uuu.com
Thanks
- User SFDC
- June 15, 2016
- Like
- 0
- Continue reading or reply
How to pass the id from visualforce page when i click the preview button
When i click on the preview button the id of the associated record id should get passed to the controller. Its urgent
- Amit Visapurkar 5
- June 15, 2016
- Like
- 0
- Continue reading or reply
Insert logic to avoid record with duplicate name and owner, but allows duplicate name with different record owner
Hi,
Can somebody help me with the logic on the following:
Account List name is existing, but the ownerid is not existing (Different user) -> insert ok
Account List name is not existing, but owner id is existing in db - insert ok
Account List name is existing, owner id is existing (Avoid duplicate record with the same Account List name with the same owner) -> No insert
Basically, I just want to prevent the record to be inserted if the account list name is duplicate and also the same owner, but if the account list has a match in the database, but it's owner is different, it's should be inserted.
Here is my current code:
Thanks for the help..
Can somebody help me with the logic on the following:
Account List name is existing, but the ownerid is not existing (Different user) -> insert ok
Account List name is not existing, but owner id is existing in db - insert ok
Account List name is existing, owner id is existing (Avoid duplicate record with the same Account List name with the same owner) -> No insert
Basically, I just want to prevent the record to be inserted if the account list name is duplicate and also the same owner, but if the account list has a match in the database, but it's owner is different, it's should be inserted.
Here is my current code:
public with sharing class InsertAccountListRec_TEST_cls { List<User> usersIdList; Set<Id> usersIdSet = new Set<Id>(); Set<Id> AffFromAcctSet = new Set<Id>(); Set<Id> xAcctListOidSet = new Set<Id>(); Set<String> xAcctListNameSet = new Set<String>(); List<Affiliation_vod__c> allAffParentRecs = new List<Affiliation_vod__c>(); List<Account_List_vod__c> newAccListRecList = new List <Account_List_vod__c>(); List<Account_List_vod__c> xAcctListRecs = new List <Account_List_vod__c>(); List<Account_List_vod__c> InsertedAccList = new List <Account_List_vod__c>(); //Creation a list of all Parent Affiliation Records, then add to allParentRecsSet (SET). //Start of 1st Block public InsertAccountListRec_TEST_cls(){ allAffParentRecs = new List<Affiliation_vod__c>([SELECT Id, OwnerId, From_Account_vod__c, From_Account_Value__c, To_Account_vod__c FROM Affiliation_vod__c WHERE (From_Account_vod__r.Id = '0011200001GNrb0AAD' AND Parent_vod__c = True) AND OwnerId IN: getActiveUsers()]); System.debug('Parent Affiliation Record Count '+ allAffParentRecs.size()); for(Account_List_vod__c xAcctListRecs : [Select OwnerId, Name FROM Account_List_vod__c WHERE Name LIKE 'HO_%' AND OwnerId IN: getActiveUsers()]){ xAcctListOidSet.add(xAcctListRecs.OwnerId); xAcctListNameSet.add(xAcctListRecs.Name); } System.debug('Account List Record Count '+ xAcctListRecs); for(Affiliation_vod__c allParentAffRecs: allAffParentRecs){ if(!AffFromAcctSet.contains(allParentAffRecs.From_Account_vod__c)){ Account_List_vod__c AccListRec = new Account_List_vod__c(); AccListRec.Name = 'HO_' + allParentAffRecs.From_Account_Value__c; AccListRec.Icon_Name_vod__c = '0'; AccListRec.OwnerId = allParentAffRecs.OwnerId; AffFromAcctSet.add(allParentAffRecs.From_Account_vod__c); newAccListRecList.add(AccListRec); } } for(Account_List_vod__c acctListToCreate : newAccListRecList){ if(xAcctListNameSet.contains(acctListToCreate.Name) && !xAcctListOidSet.contains(acctListToCreate.OwnerId)){ InsertedAccList.add(acctListToCreate); } } insert InsertedAccList ; System.debug('New Account List Records: ' + InsertedAccList); }//end of 1st block public Set<Id> getActiveUsers(){ usersIdList = new List<User>([SELECT Id FROM User WHERE (Profile_Name_vod__c LIKE '%Eisai_Epilepsy%' OR Profile_Name_vod__c LIKE '%Eisai_PrimaryCare%') AND IsActive = TRUE]); for(User users : usersIdList){ usersIdSet.add(users.Id); } return usersIdSet; } }// End of ClassThe logic which is not working is in line 47 to 51
Thanks for the help..
- Yoni Legacy
- June 15, 2016
- Like
- 0
- Continue reading or reply
Multiple Objects in Pageblock table using Wrapper class: Error: tt Compile Error: Illegal assignment from List<Account> to List<RNK.account> at line 9 column 9
<apex:page controller="tt">
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapper}" var="wrap">
<apex:column headerValue="Account Name" value="{!wrap.accRec.Name}"/>
<!-- you can add related fields here -->
<apex:column headerValue="Contact Name" value="{!wrap.conRec.Name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Controller:
public class tt
{
public List<Account> accLst {get; set;}
public List<Contact> conLst {get; set;}
public List<MyWrapper> wrapper {get; set;}
public tt()
{
accLst = [select id,name from account ] ;
conLst = [select id,name from contact ] ;
wrapper = new List<MyWrapper>() ;
for(Integer i=0 ;i<20;i++)
wrapper.add(new MyWrapper(accLst[i] , conLst[i])) ;
}
public class MyWrapper
{
public Account accRec {get; set;}
public Contact conRec {get; set;}
public MyWrapper(Account acc , Contact con)
{
accRec = acc ;
conRec = con ;
}
}
}
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapper}" var="wrap">
<apex:column headerValue="Account Name" value="{!wrap.accRec.Name}"/>
<!-- you can add related fields here -->
<apex:column headerValue="Contact Name" value="{!wrap.conRec.Name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Controller:
public class tt
{
public List<Account> accLst {get; set;}
public List<Contact> conLst {get; set;}
public List<MyWrapper> wrapper {get; set;}
public tt()
{
accLst = [select id,name from account ] ;
conLst = [select id,name from contact ] ;
wrapper = new List<MyWrapper>() ;
for(Integer i=0 ;i<20;i++)
wrapper.add(new MyWrapper(accLst[i] , conLst[i])) ;
}
public class MyWrapper
{
public Account accRec {get; set;}
public Contact conRec {get; set;}
public MyWrapper(Account acc , Contact con)
{
accRec = acc ;
conRec = con ;
}
}
}
- admin 7
- June 15, 2016
- Like
- 0
- Continue reading or reply
Creating FAQs
Hi,
I am new to Salesforce and it would be great, if community can give me some idea to create FAQs. Do I have to treat FAQ as knowledge article and proceed to create custom object for the same?
I am new to Salesforce and it would be great, if community can give me some idea to create FAQs. Do I have to treat FAQ as knowledge article and proceed to create custom object for the same?
- Sourav Sengupta 8
- June 15, 2016
- Like
- 0
- Continue reading or reply
Create custom button to bulk-add person accounts to custom object
Hi there, currently struggling with this slight problem:
I have created a custom object called "List", with a child custom object nested within that called "Person Accounts" (the name field is set to be an auto number on that one). Other than the master-detail relationship it has to "List" it also has a master detail relationship to Accounts (with a filter to limit it to person accounts only), enabling me to add person accounts to specific lists.
I now want to create a custom button that should sit on the account view that enables me o bulk add several people to a list of my choosing. Is that possible?
I have created a custom object called "List", with a child custom object nested within that called "Person Accounts" (the name field is set to be an auto number on that one). Other than the master-detail relationship it has to "List" it also has a master detail relationship to Accounts (with a filter to limit it to person accounts only), enabling me to add person accounts to specific lists.
I now want to create a custom button that should sit on the account view that enables me o bulk add several people to a list of my choosing. Is that possible?
- Edward East
- June 15, 2016
- Like
- 0
- Continue reading or reply
Creating my own Web Form
Hi everyone,
I would like to create a web form to feed the contact standard object and a couple of custom objects.
I've been looking everywhere and all I can find is how to build an App, which is not what I want.
Can anyone direct me to a tutorial that shows me how to do that?
All I really need is to understand how to create a new page based on the Contacts object.
Thanks
Nitzan
I would like to create a web form to feed the contact standard object and a couple of custom objects.
I've been looking everywhere and all I can find is how to build an App, which is not what I want.
Can anyone direct me to a tutorial that shows me how to do that?
All I really need is to understand how to create a new page based on the Contacts object.
Thanks
Nitzan
- Nitzan Marinov
- August 10, 2015
- Like
- 0
- Continue reading or reply
Refresh VF Page after method executes
Hi,
I need to refresh the whole VF Page once my delete method executes. I have wriiten the below code. When I delete a particular record, the record is getting deleted but the page is not refreshing to show the updated records. Please help.
VF Page:
<apex:page controller="viewdept_con" showHeader="false " id="mypage">
<apex:form >
<apex:pageBlock >
<apex:pageblockTable value="{!deptlist}" var="item">
<apex:column headerValue="Action">
<apex:commandLink value="Detail" action="{!deptdetail}"/><b> | </b>
<apex:commandLink value="Del" action="{!deptdelete}" reRender="mypage">
<apex:param name="deptid" value="{!item.id}" assignTo="{!deptid}"/>
</apex:commandlink>
</apex:column>
<apex:column value="{!item.name}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class viewdept_con {
public list<department__c> deptlist { get; set; }
public id deptid {get; set;}
public department__c dept {get; set;}
public viewdept_con()
{
deptlist = [select id, name from department__c];
}
public pagereference deptdetail()
{
pagereference pg = new pagereference('/apex/DepartmentDetail?deptid=' + deptid);
return pg;
}
public pagereference deptdelete()
{
dept = [select id, name from department__c where id = :deptid];
delete dept;
return null;
}
}
Thank you,
Satya
I need to refresh the whole VF Page once my delete method executes. I have wriiten the below code. When I delete a particular record, the record is getting deleted but the page is not refreshing to show the updated records. Please help.
VF Page:
<apex:page controller="viewdept_con" showHeader="false " id="mypage">
<apex:form >
<apex:pageBlock >
<apex:pageblockTable value="{!deptlist}" var="item">
<apex:column headerValue="Action">
<apex:commandLink value="Detail" action="{!deptdetail}"/><b> | </b>
<apex:commandLink value="Del" action="{!deptdelete}" reRender="mypage">
<apex:param name="deptid" value="{!item.id}" assignTo="{!deptid}"/>
</apex:commandlink>
</apex:column>
<apex:column value="{!item.name}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class viewdept_con {
public list<department__c> deptlist { get; set; }
public id deptid {get; set;}
public department__c dept {get; set;}
public viewdept_con()
{
deptlist = [select id, name from department__c];
}
public pagereference deptdetail()
{
pagereference pg = new pagereference('/apex/DepartmentDetail?deptid=' + deptid);
return pg;
}
public pagereference deptdelete()
{
dept = [select id, name from department__c where id = :deptid];
delete dept;
return null;
}
}
Thank you,
Satya
- Satya413
- July 14, 2015
- Like
- 0
- Continue reading or reply
Hi all need urgent
Contract Object
I need to generate a report that can show elapsed number of days between;
-Site Survey Scheduled (date field) and Site Survey Complete (date field).
So what are the steps?
I need to generate a report that can show elapsed number of days between;
-Site Survey Scheduled (date field) and Site Survey Complete (date field).
So what are the steps?
- rupesh ranjan
- September 16, 2015
- Like
- 1
- Continue reading or reply