• arjunm
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 6
    Replies

VF page

<apex:page Controller="Assignmentnew">
<apex:panelGrid columns="2">
<apex:form id="all" >
<apex:pageBlock >
<apex:pageBlockButtons location="top" >
<apex:commandButton value="new" action="{!doNewrecord}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!accList}" var="a">
<apex:column headerValue="Name">
<apex:outputLink value="/{!a.id}/d?retURL=/apex/AssignmentNew">
{!a.name}
</apex:outputLink>
</apex:column>
<apex:column headerValue="Buttons">
<apex:outputLink value="/{!a.id}/e?retURL=/apex/{!a.Name}">
Edit
</apex:outputLink>
<apex:commandLink action="{!delAccount}" reRender="all">Del
<apex:param value="{!a.Id}" assignTo="{!SelectedAccountId} "/>
</apex:commandLink >
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:panelGrid>
</apex:page>

 

 

 

Class ::

 

public class Assignmentnew
{

public List<Account> accList {get; set;}
public string SelectedAccountId {get; set;}

public Assignmentnew()
{
setupAccount();
}

public void setupAccount()
{
accList = [Select name, id from Account ];
}

public Pagereference doNewrecord()
{
Pagereference newRecord= new Pagereference ('/001/e?retURL=/001/');
return newRecord;
}

public PageReference delAccount()
{
accList = [select id,name from account where id=:SelectedAccountId];
if(accList .size() > 0 || accList[0].Id != ''){
delete accList;
}
setupAccount();
return null;
}

}

 

Error:


List index out of bounds: 0

Error is in expression '{!delAccount}' in component <apex:page> in page assignmentnew 

An unexpected error has occurred. Your development organization has been notified.

 

Can anyone help me with this code.

 

Thanks

Ishan

Hi, i'm trying to create a new user from PortalSite , but it's giving me this error:

 

 

The error message is portal account owner must have a role,

 

so i try to give a role to my  Site Guest User

for setup-->develop--->sites-->clicking on Site Label Name--->clicking on public Access Setting--->clicking on view users--->clicking on Edit there is a no Role Field

 

how to set a role for my  Site Guest User ?

 

Regards

Arjun

 

 

  • August 22, 2013
  • Like
  • 0

 

hi all

 

I Created Remote Access

i got the values as  Consumer Key,Consumer Secret

 

 the Web Server OAuth Authentication Flow

 

 

https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=
xxxxxxxxxxxxx&redirect_uri=https://appliction.com&state=mystate

 

in above url I got the Code value

 

https://appliction.com/?code=xxxxxxxxxxxxxx&state=mystate

 

next i put below url 

https://login.salesforce.com/services/oauth/token?code=xxxxxxxxxxx&grant_type=authorization_code&client_id=xxxxxxx&client_secret=xxxxxx&redirect_uri=https://appliction.com

it show error as

 

<OAuth><error>invalid_grant</error><error_description>expired authorization code</error_description></OAuth>

 

What Is a grant_type

How will get grant_type value

 

i am new to rest webservices in apex ,  please provide detailled information about  how to run simple programm Post For  Rest api

 

 

Thanks&Regards

arjun

 

 

 

 

 

Hi, i'm trying to create a new user from PortalSite , but it's giving me this error:

 

 

The error message is portal account owner must have a role,

 

so i try to give a role to my  Site Guest User

for setup-->develop--->sites-->clicking on Site Label Name--->clicking on public Access Setting--->clicking on view users--->clicking on Edit there is a no Role Field

 

how to set a role for my  Site Guest User ?

 

Regards

Arjun

 

 

  • August 22, 2013
  • Like
  • 0

I have a working trigger, if criteria is met, 2 leads are cloned and assigned to 2 additional partners. But I can not seem to figure out a test class for it.

 

trigger FTGClone on Lead (after insert)
{
Lead L = trigger.new[0];
if(L.Category__c  == 'FTG' && L.Clone_Version__c == '0' && L.LeadSource != 'Self Generated' && L.Number_of_Units__c >= 50)
{
Lead[] LeadClone = new Lead[0];

map<id,Lead> entries = new map<id,Lead>(); 

for(Lead record:trigger.new)
entries.put(record.id,null); 
entries.putall([select id,Name, Company, LastName, FirstName,Lead_Source_External__c, Number_of_TVs__c, Email, Location_of_Service__c, Building_Stories__c, MobilePhone, Phone, Business_Phone_Ext__c, Business_Phone__c, Number_of_Units__c, Number_of_Locations__c, Type_of_Business__c, Business_Address__c, Business_State__c, Business_City__c, Business_Zipcode__c from Lead where id in :entries.keyset()]); 


for(Lead record:trigger.new) 
LeadClone.add(new Lead ( Ownerid='00G60000001G9uA', Original_Lead_Id__c=record.Id,Company=entries.get(record.id).Company,LastName=entries.get(record.id).LastName,FirstName=entries.get(record.id).FirstName,Clone_Version__c='1',Lead_Source_External__c=entries.get(record.id).Lead_Source_External__c,Number_of_TVs__c=entries.get(record.id).Number_of_TVs__c, Email=entries.get(record.id).Email, Location_of_Service__c=entries.get(record.id).Location_of_Service__c, Building_Stories__c=entries.get(record.id).Building_Stories__c, MobilePhone=entries.get(record.id).MobilePhone, Phone=entries.get(record.id).Phone, Business_Phone_Ext__c=entries.get(record.id).Business_Phone_Ext__c, Business_Phone__c=entries.get(record.id).Business_Phone__c, Number_of_Units__c=entries.get(record.id).Number_of_Units__c, Number_of_Locations__c=entries.get(record.id).Number_of_Locations__c, Type_of_Business__c=entries.get(record.id).Type_of_Business__c, Business_Address__c=entries.get(record.id).Business_Address__c, Business_State__c=entries.get(record.id).Business_State__c, Business_City__c=entries.get(record.id).Business_City__c, Business_Zipcode__c=entries.get(record.id).Business_Zipcode__c));

for(Lead record:trigger.new) 
LeadClone.add(new Lead ( Ownerid='00G60000001G9uF', Original_Lead_Id__c=record.Id,Company=entries.get(record.id).Company,LastName=entries.get(record.id).LastName,FirstName=entries.get(record.id).FirstName,Clone_Version__c='2',Lead_Source_External__c=entries.get(record.id).Lead_Source_External__c,Number_of_TVs__c=entries.get(record.id).Number_of_TVs__c, Email=entries.get(record.id).Email, Location_of_Service__c=entries.get(record.id).Location_of_Service__c, Building_Stories__c=entries.get(record.id).Building_Stories__c, MobilePhone=entries.get(record.id).MobilePhone, Phone=entries.get(record.id).Phone, Business_Phone_Ext__c=entries.get(record.id).Business_Phone_Ext__c, Business_Phone__c=entries.get(record.id).Business_Phone__c, Number_of_Units__c=entries.get(record.id).Number_of_Units__c, Number_of_Locations__c=entries.get(record.id).Number_of_Locations__c, Type_of_Business__c=entries.get(record.id).Type_of_Business__c, Business_Address__c=entries.get(record.id).Business_Address__c, Business_State__c=entries.get(record.id).Business_State__c, Business_City__c=entries.get(record.id).Business_City__c, Business_Zipcode__c=entries.get(record.id).Business_Zipcode__c));


insert LeadClone; }}

I have a parent/child relationship on a lookup table.  When I bring up the tab for the parent I get the child default auto number.  I can bring up the description when I hover ofer the auto number. 

 

What I want to do is get the description, not the auto number, when I list the parent records in the parent tab. 

 

Book Name    Type (Hard Cover/Soft Cover)

Book 1              0001

Book 2              0002

 

In the list I want the Type description (Soft Cover) and not 0001.  Is this possible?

 

Thanks.

 

 

I created a custom object called Impressions. Every time a Opportunity Product is created with a Product Family = Impressions I would like copy some fields from this Opportunity Product and insert them into a new row on the Impressions object. 

 

For example if I add an Impression Product to an Opportunity with the Quantity of 50 and a Date of 6/1/2013, I would like a new row to be created in the Impressions object with ID = 1 (Autonumber), Quantity = 50, and Date = 6/1/2013.

 

Here is the code that I have. It is not triggering any errors. I have placed the trigger in the Opportunit Product triggers, and it is active; however, when I create a new object to see if it works, it does not. Can anyone offer any assistance?? I think the code is OK, but maybe I'm missing something?? Your help is EXTREMELY appreicated!

 

trigger createImpression on OpportunityLineItem (after insert) {

List <Impressions__c> impToInsert = new List <Impressions__c> ();

for (OpportunityLineItem o : Trigger.new) {

// Check if Opportunity Product Meets my criteria
if (o.Product_Family__c == 'Impression') {

Impressions__c i = new Impressions__c (); //Instantiating new object to put values for future record

// Mapping Opportunity Product fields to new Impressions object

i.Bill_Date__c = o.ServiceDate;
i.Expected_Impressions__c = o.Quantity;
i.Predicted_Revenue__c = o.TotalPrice;
//Adding new object to list that will be inserted. 

impToInsert.add(i);

}

}

//Loop has finished; Inserting new records in SF
try {
insert impToInsert; 
} catch (system.Dmlexception e) {
system.debug (e);
}

}
 

 Thank you!

VF page

<apex:page Controller="Assignmentnew">
<apex:panelGrid columns="2">
<apex:form id="all" >
<apex:pageBlock >
<apex:pageBlockButtons location="top" >
<apex:commandButton value="new" action="{!doNewrecord}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!accList}" var="a">
<apex:column headerValue="Name">
<apex:outputLink value="/{!a.id}/d?retURL=/apex/AssignmentNew">
{!a.name}
</apex:outputLink>
</apex:column>
<apex:column headerValue="Buttons">
<apex:outputLink value="/{!a.id}/e?retURL=/apex/{!a.Name}">
Edit
</apex:outputLink>
<apex:commandLink action="{!delAccount}" reRender="all">Del
<apex:param value="{!a.Id}" assignTo="{!SelectedAccountId} "/>
</apex:commandLink >
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:panelGrid>
</apex:page>

 

 

 

Class ::

 

public class Assignmentnew
{

public List<Account> accList {get; set;}
public string SelectedAccountId {get; set;}

public Assignmentnew()
{
setupAccount();
}

public void setupAccount()
{
accList = [Select name, id from Account ];
}

public Pagereference doNewrecord()
{
Pagereference newRecord= new Pagereference ('/001/e?retURL=/001/');
return newRecord;
}

public PageReference delAccount()
{
accList = [select id,name from account where id=:SelectedAccountId];
if(accList .size() > 0 || accList[0].Id != ''){
delete accList;
}
setupAccount();
return null;
}

}

 

Error:


List index out of bounds: 0

Error is in expression '{!delAccount}' in component <apex:page> in page assignmentnew 

An unexpected error has occurred. Your development organization has been notified.

 

Can anyone help me with this code.

 

Thanks

Ishan