• Antoine_Leleu
  • NEWBIE
  • 0 Points
  • Member since 2012
  • Salesforce Administrator


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

Hello,

 

I would like create an apex code and a visualforce page to display the acount information of the current user in the customer portal.

 

This my code :

 

Apex class :

public with sharing class CustomerPortalController {

//variables
Id idCurrent = UserInfo.getUserId();
public user UserCurrent{get;set;}
public account AccountCurrentUser{get;set;}

  public CustomerPortalController(){
    
    UserCurrent = [SELECT AccountName__c FROM user WHERE Id=:idCurrent];
    
    AccountCurrentUser = [SELECT OwnerId, PreSales__c FROM account WHERE Name=:UserCurrent.AccountName__c];
  }
}

 

Page :

<apex:page controller="CustomerPortalController" tabstyle="Account" showHeader="false">

Your Pre-Sales is {!AccountCurrentUser.PreSales__c}

</apex:page>

 

Problem : the custom field "PreSales__c" is a lookup(user) and the page display the ID.

How can i display the name ?

 

Thanks,

Antoine

Hello,

 

I tried to write an apex code to sum the field of child related list obect.

 

I have 2 custom objects : "Server__c" and "Component__c"

i have a field, type :number, called "Memory__c" in the component object.

there are n Components related to Server.

 

I would like to sum the Memory of each component related to my server.

 

i tried this, but it doesn't work. I'm new in the apexcode

 

public class CustomserverController {

Id idServer = null;
Integer SumMemory = 0;

public CustomChassisController(ApexPages.StandardController conMain) {
// Set Variables
idServer = conMain.getId();
}

List<Server__c> LstServer = [SELECT (select Memory__c FROM Components__r) FROM Server__c WHERE Id = :idServer];

for(Server__c a: LstServer)
{
for(Components__c o: a.Components__r)
{
SumMemory += Memory__c;
}
}
}

 

Thanks for your help

 

Antoine

 

Hello,

 

I created a custom controler in apex classes to create automaticly  a task.

 

I would like assign my task to a Public Group called "Production". I tried this :

 

tskNew = new Task();

tskNew.OwnerId = [SELECT Id,Name FROM Group WHERE Name ='Production' limit 1].Id;

 

But it doesn't work. i have this message : Assigned To: Assigned To ID: id value of incorrect type: 00GW0000000JXiSMAW

 

Thanks for your help.

 

Antoine

 

Hello,

 

I would like create an apex code and a visualforce page to display the acount information of the current user in the customer portal.

 

This my code :

 

Apex class :

public with sharing class CustomerPortalController {

//variables
Id idCurrent = UserInfo.getUserId();
public user UserCurrent{get;set;}
public account AccountCurrentUser{get;set;}

  public CustomerPortalController(){
    
    UserCurrent = [SELECT AccountName__c FROM user WHERE Id=:idCurrent];
    
    AccountCurrentUser = [SELECT OwnerId, PreSales__c FROM account WHERE Name=:UserCurrent.AccountName__c];
  }
}

 

Page :

<apex:page controller="CustomerPortalController" tabstyle="Account" showHeader="false">

Your Pre-Sales is {!AccountCurrentUser.PreSales__c}

</apex:page>

 

Problem : the custom field "PreSales__c" is a lookup(user) and the page display the ID.

How can i display the name ?

 

Thanks,

Antoine

Hello,

 

I tried to write an apex code to sum the field of child related list obect.

 

I have 2 custom objects : "Server__c" and "Component__c"

i have a field, type :number, called "Memory__c" in the component object.

there are n Components related to Server.

 

I would like to sum the Memory of each component related to my server.

 

i tried this, but it doesn't work. I'm new in the apexcode

 

public class CustomserverController {

Id idServer = null;
Integer SumMemory = 0;

public CustomChassisController(ApexPages.StandardController conMain) {
// Set Variables
idServer = conMain.getId();
}

List<Server__c> LstServer = [SELECT (select Memory__c FROM Components__r) FROM Server__c WHERE Id = :idServer];

for(Server__c a: LstServer)
{
for(Components__c o: a.Components__r)
{
SumMemory += Memory__c;
}
}
}

 

Thanks for your help

 

Antoine