-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
13Questions
-
43Replies
Visualforce Page help
Hello all,
I am writting a visual force page for the task object, to display some activitives in a different page based on the Subject.
This is the error i am getting with my code. Can anyone point me in the rigth direction please:
Error: Compile Error: Illegal assignment from LIST<Task> to LIST<Task> at line 19 column 4
public class MarketingGeniusTasksController
{
List<Task> tk;
public MarketingGeniusTasksController(ApexPages.StandardController Controller)
{
}
Public List<Task> getResults()
{
return tk;
}
public PageReference gettk()
{
String userId=UserInfo.getUserId();
UserId=userId.Substring(0,15);
System.debug('UserId=='+UserId);
tk=[Select Status, Subject, Priority, OwnerId, Owner.Name, WhatId, What.Name, WhoId, Who.Name, Vmail__c, RecordTypeId, LastModifiedDate, from Task where Subject='Enterprise Marketing Genius Email']; --> Line 19 error
return Null;
}
Static testMethod void testMarketingGeniusTasksController()
{
user testUser=[Select Id from user where ProfileId='00e30000000eFWd' AND IsActive=true Limit 1];
ApexPages.StandardController sc = new ApexPages.StandardController(testUser);
System.RunAs(testUser)
{
MarketingGeniusTasksController testMGT = New MarketingGeniusTasksController(sc);
testMGT.gettk();
testMGT.getResults();
}
}
}
- Tinku
- February 17, 2011
- Like
- 0
- Continue reading or reply
Visual force page to display the Activity History
Hello all,
I am new to salesforce. And this is my first try at VisualForce Page in an organization.
The requirement is to display the activity history in a seperate page. Right now, since activity history is a related list in Accounts/Contacts, the information gets displayed in the same page as in Accounts/contacts.
I am planning to write a VF page and give a button on the related list, which will take the users to a new page of activity history.
Here is the VF page and the related class. I am getting a List has no rows for assignment to SObject errors.The error comes when i click the button.
Can anyone please help me out.
<apex:page standardController="Task" extensions="MarketingGeniusTasksController">
<apex:form >
<h1>Activity History: Marketing Genius Emails</h1>
<apex:pageblock >
<apex:pageBlockTable value="{!Task}" var="Task" >
<apex:column headerValue="Status"/>
<apex:outputfield value="{!task.Status}"/>
<apex:column headerValue="Subject"/>
<apex:outputfield value="{!task.Subject}"/>
<apex:column headerValue="Priority"/>
<apex:outputfield value="{!task.Priority}"/>
<apex:column headerValue="TLC Activity Type"/>
<apex:outputfield value="{!task.Vmail__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public class MarketingGeniusTasksController
{
Task tk;
Task tsk;
public MarketingGeniusTasksController(ApexPages.StandardController stdController)
{
this.tk = (Task)stdController.getRecord();
tsk = [Select Status, Subject, Priority, Vmail__c from Task where Id=:tk.Id]; -->error at this line.
}
public string getStatus(){
return tsk.Status;
}
public string getSubject(){
return tsk.Subject;
}
public string getPriority(){
return tsk.Priority;
}
public string getTLCActivityType(){
return tsk.Vmail__c;
}
}
- Tinku
- February 15, 2011
- Like
- 0
- Continue reading or reply
Trigger Help
Trigger which creates Entitlements and also updates a field on Account. Since it is updating a field on Account, i cannot use (After Insert, After Update). When i use (before insert, before update) It gives me this error:
Apex trigger createEntitlement caused an unexpected exception, contact your administrator: createEntitlement: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Account Name]: [Account Name]: Trigger.createEntitlement:
I need some ideas on how to change the logic in this trigger to create the new Entitlement.
trigger createEntitlement on Account (before insert, before update)
{
DateTime dt=System.now();
set<Id> PersonAccountsId = new set<Id>();
List<ServiceContract> newServiceContract=New List<ServiceContract>();
List<Entitlement> newEntitlement=New List<Entitlement>();
map<string, String> ServiceContractMap = new map<string,string>();
map<string, String> EntitlementMap = new map<string,string>();
RecordType accRecType=[Select Id From RecordType Where Name=:'Subscriber' And SobjectType=:'Account' limit 1];
if(Trigger.IsInsert )
{
List<string> accIdList = new List<String>();
Map<String,String> accConMap = new map<String,String>();
for(Account acc : trigger.New)
{
if(acc.RecordTypeId == accRecType.Id)
{
accIdList.add(acc.Id);
acc.Premium_Upgrade_Date__c=dt.date();
}
}
if(accIdList.size() > 0 )
{
for(Account pa:Trigger.New)
{
ServiceContract sc; Entitlement entl;
if(pa.RecordTypeId==accRecType.Id && pa.JSC_Membership_Type__c=='Premium')
{
sc=New ServiceContract(OwnerId=pa.OwnerId, Name='JSA', AccountId=pa.ID);
sc.StartDate = dt.date();
newServiceContract.Add(sc);
database.insert(newServiceContract);
entl=New Entitlement (Entitlement_owner__c=pa.OwnerId, Name='JSA', AccountId=pa.ID,ServiceContractId=sc.Id, SlaProcessId='552R00000004CGs');
entl.StartDate = dt.date();
newEntitlement.Add(entl);
database.insert(newentitlement); <-- error here
}
}
}
}
}
- Tinku
- February 04, 2011
- Like
- 0
- Continue reading or reply
Master-detail between 2 objects
How to create a custom object with a Master-Detail relationship with another custom object?
- Tinku
- February 02, 2011
- Like
- 0
- Continue reading or reply
Exit Syntax
What is the Exit syntax for Trigger?
REquirement is:
If(a==True)
Exit(); --> it should exit the trigger without executing next block of code.
else
{
code_block
}
- Tinku
- January 27, 2011
- Like
- 0
- Continue reading or reply
SOQL Governer Limit with Trigger
In my Organization there are totally 4 triggers on Opportunity and 4 triggers on Account. Each trigger fires 2 or 3 SOQL statements. None of the triggers have SOQL statements inside For or If loop.
When i create a Opportunity, it fires all these 8 triggers and thus hitting Governer Limits.
Any suggestions on How to proceed from here?
- Tinku
- January 27, 2011
- Like
- 0
- Continue reading or reply
Trigger on an Account inactivity
Hey guys,
I need some suggestions on how to write a trigger for this particular criteria.
Scenario is like this: An Account is created.And there is No activity on the account for 3 weeks. (no update, or delete).
I need to write a trigger for this inactivity, on Account. I am stumped because until and unless there is some action on account, my trigger wont get fired.
so i need some suggestions on how to move forward with this.
- Tinku
- January 26, 2011
- Like
- 0
- Continue reading or reply
Trigger Error
This is the trigger i have written on Case object which updates a field in Account object. When i am closing a case, the following error shows up.
for(Case ca:Trigger.New)
{
Id1=ca.AccountId;
Account acct=[Select a.id, a.Name, a.Last_Contacted_date__c, a.Contacted__c from Account a where a.Id=:ID1];
if(ca.Subject=='New Member Outreach' && ca.Status=='Closed' && ca.AccountId==acct.Id)
{
acct.Contacted__c=True;
acct.Last_Contacted_date__c=ca.ClosedDate;
}
database.update(acct); --> Error: at this line
}
}
Error is: updateAccount_Premium: execution of AfterUpdate
caused by: System.DmlException: Update failed. First exception on row 0
with id 001P000000GIss5IAD; first error:
INVALID_FIELD_FOR_INSERT_UPDATE, Account: bad field names on
insert/update call: Name: [Name]: Trigger.updateAccount_Premium:
- Tinku
- January 25, 2011
- Like
- 0
- Continue reading or reply
syntax for Contains(string)
am writing a code, where i need to compare the name which contains some specific letters. what is the syntax for it?
Account acc;
(if acc.Name Contains 'ABC')
{
}
- Tinku
- January 20, 2011
- Like
- 0
- Continue reading or reply
syntax to know the day of the week
What is the syntax to know the Day of the week.
And also to subtract one date field with Today's date.
the requirement is like this:
If(Today=Friday)
{
if( (account.createdDate - Today) > 21 || (Today - account.CreatedDate) >21 )
{
Create case;
}
}
I need the help with the Blue Link part.
- Tinku
- January 19, 2011
- Like
- 0
- Continue reading or reply
Syntax to change one datatype to another
I need help or ideas on how to change the datatype of one field into some other datatype, just inside a code.
I have this issue where:
The field "CreatedDate" in Account object is of datatype DateTime
and The field "StartDate" in ServiceContract object is of datatype Date
I need to assign account.createddate to servicecontract.startdate
It gives me error: Invalid initial expression type for field ServiceContract.StartDate, expecting: Date
How do i convert a datetime field to a date field.
In general i need to know a way to convert one datatype into another.
- Tinku
- January 18, 2011
- Like
- 0
- Continue reading or reply
Trigger on Account for creating Service Contract and Entitlement
I need to write a trigger to automatically create a service contract and entitlement, whenever a person account is created.
I have written the trigger, but the service contract and entitlement are being created for the same account every time.
The issue is with the cross-object reference. Can anyone give me any suggestions or ideas please.
trigger createEntitlement on Account (after insert, before update)
{
Set<Id> personAccountsId=New Set<Id>();
List<ServiceContract> newServiceContract=New List<ServiceContract>();
List<Entitlement> newEntitlement=New List<Entitlement>();
RecordType accRecType=[Select Id From RecordType Where Name=:'Subscriber' And SobjectType=:'Account' limit 1];
for(Account pa:Trigger.New)
{
Account acct = [Select a.OwnerId, a.id, a.Name from Account a where a.RecordTypeId=:accRectype.Id limit 1];
if(pa.RecordTypeId==accRecType.Id && pa.JSC_Membership_Type__c=='Premium')
{
ServiceContract sc=New ServiceContract(OwnerId=pa.OwnerId, Name='New Premium Upgrade', AccountId=acct.ID );
newServiceContract.Add(sc);
database.insert(newServiceContract);
}
if(pa.RecordTypeId==accRecType.Id && pa.JSC_Membership_Type__c=='Premium')
{
Entitlement entl=New Entitlement (Entitlement_owner__c=acct.OwnerId, Name='New Premium Upgrade', AccountId=acct.ID );
newEntitlement.Add(entl);
database.insert(newEntitlement);
}
}
}
- Tinku
- January 18, 2011
- Like
- 0
- Continue reading or reply
Re-assigning the Account Owner
I have a requirement, where:
Based on the 'opportunity' stage and 'account' billing state, i have to reassign the account owners to some specific users.
I am trying to write a trigger for this. When i am assigning account.owner to a user, it gives out an 'Illegal Assignment error". Can anyone please help me with this problem.
Here is the code:
trigger AccountAssignment on Opportunity (after insert, after update)
{
Account act;
for(Opportunity Opp : trigger.New[0])
{
if((opp.StageName=='Contract')&& (act.BillingState == 'ME'||
act.BillingState == 'NH'||act.BillingState == 'VT'||act.BillingState == 'NY'||act.BillingState == 'PA'||act.BillingState == 'DC'||act.BillingState == 'MD'
||act.BillingState == 'DE'||act.BillingState == 'NJ'||act.BillingState == 'CT'||act.BillingState == 'RI'||act.BillingState == 'MA'))
{
act.owner = 'Holly Esposito'; // error is at this line : Illegal assignment from String to SOBJECT:User
}
}
update Act;
}
- Tinku
- January 11, 2011
- Like
- 0
- Continue reading or reply
Visualforce Page help
Hello all,
I am writting a visual force page for the task object, to display some activitives in a different page based on the Subject.
This is the error i am getting with my code. Can anyone point me in the rigth direction please:
Error: Compile Error: Illegal assignment from LIST<Task> to LIST<Task> at line 19 column 4
public class MarketingGeniusTasksController
{
List<Task> tk;
public MarketingGeniusTasksController(ApexPages.StandardController Controller)
{
}
Public List<Task> getResults()
{
return tk;
}
public PageReference gettk()
{
String userId=UserInfo.getUserId();
UserId=userId.Substring(0,15);
System.debug('UserId=='+UserId);
tk=[Select Status, Subject, Priority, OwnerId, Owner.Name, WhatId, What.Name, WhoId, Who.Name, Vmail__c, RecordTypeId, LastModifiedDate, from Task where Subject='Enterprise Marketing Genius Email']; --> Line 19 error
return Null;
}
Static testMethod void testMarketingGeniusTasksController()
{
user testUser=[Select Id from user where ProfileId='00e30000000eFWd' AND IsActive=true Limit 1];
ApexPages.StandardController sc = new ApexPages.StandardController(testUser);
System.RunAs(testUser)
{
MarketingGeniusTasksController testMGT = New MarketingGeniusTasksController(sc);
testMGT.gettk();
testMGT.getResults();
}
}
}
- Tinku
- February 17, 2011
- Like
- 0
- Continue reading or reply
Visual force page to display the Activity History
Hello all,
I am new to salesforce. And this is my first try at VisualForce Page in an organization.
The requirement is to display the activity history in a seperate page. Right now, since activity history is a related list in Accounts/Contacts, the information gets displayed in the same page as in Accounts/contacts.
I am planning to write a VF page and give a button on the related list, which will take the users to a new page of activity history.
Here is the VF page and the related class. I am getting a List has no rows for assignment to SObject errors.The error comes when i click the button.
Can anyone please help me out.
<apex:page standardController="Task" extensions="MarketingGeniusTasksController">
<apex:form >
<h1>Activity History: Marketing Genius Emails</h1>
<apex:pageblock >
<apex:pageBlockTable value="{!Task}" var="Task" >
<apex:column headerValue="Status"/>
<apex:outputfield value="{!task.Status}"/>
<apex:column headerValue="Subject"/>
<apex:outputfield value="{!task.Subject}"/>
<apex:column headerValue="Priority"/>
<apex:outputfield value="{!task.Priority}"/>
<apex:column headerValue="TLC Activity Type"/>
<apex:outputfield value="{!task.Vmail__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public class MarketingGeniusTasksController
{
Task tk;
Task tsk;
public MarketingGeniusTasksController(ApexPages.StandardController stdController)
{
this.tk = (Task)stdController.getRecord();
tsk = [Select Status, Subject, Priority, Vmail__c from Task where Id=:tk.Id]; -->error at this line.
}
public string getStatus(){
return tsk.Status;
}
public string getSubject(){
return tsk.Subject;
}
public string getPriority(){
return tsk.Priority;
}
public string getTLCActivityType(){
return tsk.Vmail__c;
}
}
- Tinku
- February 15, 2011
- Like
- 0
- Continue reading or reply
Trigger Help
Trigger which creates Entitlements and also updates a field on Account. Since it is updating a field on Account, i cannot use (After Insert, After Update). When i use (before insert, before update) It gives me this error:
Apex trigger createEntitlement caused an unexpected exception, contact your administrator: createEntitlement: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Account Name]: [Account Name]: Trigger.createEntitlement:
I need some ideas on how to change the logic in this trigger to create the new Entitlement.
trigger createEntitlement on Account (before insert, before update)
{
DateTime dt=System.now();
set<Id> PersonAccountsId = new set<Id>();
List<ServiceContract> newServiceContract=New List<ServiceContract>();
List<Entitlement> newEntitlement=New List<Entitlement>();
map<string, String> ServiceContractMap = new map<string,string>();
map<string, String> EntitlementMap = new map<string,string>();
RecordType accRecType=[Select Id From RecordType Where Name=:'Subscriber' And SobjectType=:'Account' limit 1];
if(Trigger.IsInsert )
{
List<string> accIdList = new List<String>();
Map<String,String> accConMap = new map<String,String>();
for(Account acc : trigger.New)
{
if(acc.RecordTypeId == accRecType.Id)
{
accIdList.add(acc.Id);
acc.Premium_Upgrade_Date__c=dt.date();
}
}
if(accIdList.size() > 0 )
{
for(Account pa:Trigger.New)
{
ServiceContract sc; Entitlement entl;
if(pa.RecordTypeId==accRecType.Id && pa.JSC_Membership_Type__c=='Premium')
{
sc=New ServiceContract(OwnerId=pa.OwnerId, Name='JSA', AccountId=pa.ID);
sc.StartDate = dt.date();
newServiceContract.Add(sc);
database.insert(newServiceContract);
entl=New Entitlement (Entitlement_owner__c=pa.OwnerId, Name='JSA', AccountId=pa.ID,ServiceContractId=sc.Id, SlaProcessId='552R00000004CGs');
entl.StartDate = dt.date();
newEntitlement.Add(entl);
database.insert(newentitlement); <-- error here
}
}
}
}
}
- Tinku
- February 04, 2011
- Like
- 0
- Continue reading or reply
Exit Syntax
What is the Exit syntax for Trigger?
REquirement is:
If(a==True)
Exit(); --> it should exit the trigger without executing next block of code.
else
{
code_block
}
- Tinku
- January 27, 2011
- Like
- 0
- Continue reading or reply
Trigger on an Account inactivity
Hey guys,
I need some suggestions on how to write a trigger for this particular criteria.
Scenario is like this: An Account is created.And there is No activity on the account for 3 weeks. (no update, or delete).
I need to write a trigger for this inactivity, on Account. I am stumped because until and unless there is some action on account, my trigger wont get fired.
so i need some suggestions on how to move forward with this.
- Tinku
- January 26, 2011
- Like
- 0
- Continue reading or reply
Trigger Error
This is the trigger i have written on Case object which updates a field in Account object. When i am closing a case, the following error shows up.
for(Case ca:Trigger.New)
{
Id1=ca.AccountId;
Account acct=[Select a.id, a.Name, a.Last_Contacted_date__c, a.Contacted__c from Account a where a.Id=:ID1];
if(ca.Subject=='New Member Outreach' && ca.Status=='Closed' && ca.AccountId==acct.Id)
{
acct.Contacted__c=True;
acct.Last_Contacted_date__c=ca.ClosedDate;
}
database.update(acct); --> Error: at this line
}
}
Error is: updateAccount_Premium: execution of AfterUpdate
caused by: System.DmlException: Update failed. First exception on row 0
with id 001P000000GIss5IAD; first error:
INVALID_FIELD_FOR_INSERT_UPDATE, Account: bad field names on
insert/update call: Name: [Name]: Trigger.updateAccount_Premium:
- Tinku
- January 25, 2011
- Like
- 0
- Continue reading or reply
syntax to know the day of the week
What is the syntax to know the Day of the week.
And also to subtract one date field with Today's date.
the requirement is like this:
If(Today=Friday)
{
if( (account.createdDate - Today) > 21 || (Today - account.CreatedDate) >21 )
{
Create case;
}
}
I need the help with the Blue Link part.
- Tinku
- January 19, 2011
- Like
- 0
- Continue reading or reply