• danielfnz
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi,

I am trying to determine if it is possible to determine the static resource dynamically.

So e.g. I have 2 users who have alias of User1 and User2. I have 2 images User1.jpg and User2.jpg and they should see their corresponding image when they view the visualforce page.

I want to do something like
$Resource.($User.Alias).jpg

But I can't get the syntax right if it is at all possible.

Any advice appreciated. Thanks


Message Edited by danielfnz on 09-01-2008 03:18 AM

I have a custom object called Merchant_Analysis__c which has a master-detail relationship with Opportunity. There is a field on the custom object called Opportunity__c which is just a reference to the parent Opportunity. I have a simple javascript button on the Opportunity called  New Merchant Analysis which simply passes the opportunity id to the visualforce controller via GET.

 

In my save method for the controller I set the Merchant_Analysis__c.Opportunity__c field to the ID of the Opportunity

 

public analysisController()

{

String oid = System.currentPageReference().getParameters().get('id');

 

if(oid != null && oid != '')

{

Opportunity o = [select id,name from Opportunity WHERE id=:oid];

this.oppID = o.id;

}

}

public PageReference save()

{

analysis.Opportunity__c = oppID;

analysis.recordtypeid = recType;

insert analysis;

 

PageReference analysisPage = new PageReference('/' + analysis.id);

analysisPage.setRedirect(true);

 

return analysisPage;

}

 

 The variable oppID is a public class level String variable that holds the Opportunity ID. For some reason when I run my test methods I get the following error:

 

System.SObjectException: Field is not writeable: Merchant_Analysis__c.Opportunity__c

 I've checked all the field level securities and everything to make sure Opportunity__c is not read only anywhere. For some reason I cannot figure out how to get past this error or even what is causing it.

 

Does anyone know how I can set the the relationship field of a Custom Object with a Master-Detail Relationship?

 

 

Any help would be great, as this problem has been plaguing me for too long now.

 

 

Thanks,

Jonathan 

 

 

 

Message Edited by jbroquist on 02-26-2009 11:52 AM
Message Edited by jbroquist on 02-26-2009 11:52 AM

I have created a VF page that uses a List View to retrieve records then a radio button to mass update the selected records.  I received the following error message after selecting a View and clicking on the "Set Priority" button:

 

((toLabel(Status) LIKE '%AcOp%')) ORDER BY toLabel(Type) ASC LIMIT 10000 ^ ERROR at Row:1:Column:130 unexpected token: toLabel

 

Here is the controller:

 

 

public class CasesMassUpdatePriorityExt { public List<Case> cases; public List<Case> casesToUpdate; public String priority; private ApexPages.StandardSetController ssc; public CasesMassUpdatePriorityExt(ApexPages.StandardSetController controller) { this.ssc = controller; this.cases = (list<Case>)controller.getSelected(); } public String getPriority() { return priority; } public void setPriority(String priority) { this.priority = priority; }

 

public List<SelectOption> getPriorityItems() { List<SelectOption> options = new List<SelectOption>(); Schema.DescribeFieldResult f = Case.Priority.getDescribe(); List<Schema.PicklistEntry> ple = f.getPicklistValues(); for (Schema.PicklistEntry pl : ple) { String plstr = pl.getValue(); options.add(new SelectOption(plstr,plstr)); system.debug('****plstr=' + plstr); } system.debug('****getPriorityItems=' + options); return options; }

public List<Case> getCases(){ return cases; } public PageReference save() { if (cases.size() > 0) { casesToUpdate = new List<Case>(); for (Case c : cases) { Case selCase = new Case ( id = c.Id); selCase.priority = priority; system.debug('*****Save:selcase.priority=' + selCase.priority + ' Priority=' + priority); casesToUpdate.add(selCase); } update casesToUpdate;

} PageReference myPage = new PageReference('/500/o'); myPage.setRedirect(true); return myPage; }

}

 

Here is the page:

 

<apex:page standardController="Case" extensions="CasesMassUpdatePriorityExt" recordSetvar="cases" Tabstyle="Case"> <apex:form > <apex:pageblock > <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:selectRadio value="{!priority}"> <apex:selectOptions value="{!priorityItems}"/> </apex:selectRadio> <apex:pageblockTable value="{!cases}" var="s" > <apex:column value="{!s.Subject}"/> <apex:column value="{!s.Account.Name}"/> <apex:column value="{!s.Contact.Name}"/> <apex:column value="{!s.CaseNumber}"/> <apex:column value="{!s.Priority}"/> </apex:pageblockTable> </apex:pageblock> </apex:form> </apex:page>

 


  • February 18, 2009
  • Like
  • 0
Hi,

I am trying to determine if it is possible to determine the static resource dynamically.

So e.g. I have 2 users who have alias of User1 and User2. I have 2 images User1.jpg and User2.jpg and they should see their corresponding image when they view the visualforce page.

I want to do something like
$Resource.($User.Alias).jpg

But I can't get the syntax right if it is at all possible.

Any advice appreciated. Thanks


Message Edited by danielfnz on 09-01-2008 03:18 AM