• Dev@Force.ax647
  • NEWBIE
  • 95 Points
  • Member since 2010

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 28
    Replies
I am recieving the following message when clicking on the custom button: "Problem with OnClick JavaScript button - unexpected end of input".

The issue is with the script written on !Opportunity. Amount. I am trying to write that the opportunity cannot be approved in PMI when the Amount field is BLANK.

Please help! Thanks! Beth
 
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")} 

var strStatus = '{!Opportunity.Opportunity_Status__c}'; 
switch(strStatus) { 
case 'Denied': 
alert('This opportunity cannot be approved because it has been denied.'); 
break; 
case 'Closed': 
case 'Awaiting Claim': 
case 'Claim Submitted': 
case 'Closed Expired': 
case 'Closed Won': 
case 'Closed Lost': 
alert('This opportunity cannot be updated.'); 
break; 
var strAmount = '{!Opportunity.Amount}'; 
switch(strAmount){ 
case 'Null': 
alter('This opportunity cannot be approved because no products are listed.'); 
break; 
default: 
sforce.apex.execute("CMR_DesignWebService", "ApproveToPMIDesign",{OpportunityId:'{!Opportunity.Id}'}); 
alert('Opportunity Approved in PMI system.'); 
window.location = window.location; 
break; 
}

 

My question is, if I have input fields that are named with the same ID multiple times, what is the syntax to pass the inputted value into my APex class:

 

For example: I have the following that is in a loop for the number of financial accounts I returned in a query. So I may have ONE or MANY of these

     my loop...

                 <tr>
                    <td align="right">From Date:(mm/dd/yyyy)</td>
                    <td><apex:inputText id="fromDate" value="{!fromDate}"/></td>  
                    
                </tr>  
                <tr>
                    <td align="right">To Date:(mm/dd/yyyy)</td>
                    <td><apex:inputText id="toDate" value="{!toDate}"/></td>  
                    
                </tr> 

 end loop...

 

In other languages when I have had this situation I would have a field named fromDate, which would be an array of values, and if I wanted the 5th one from my input form it would be fromDate[5]. How is this done in Apex/VisualForce ?

 

If I were to name them uniquely like fromDate1, toDate1, fromDate2, toDate2, then I would have to create getter/setter for every one in the loop! There has to be an easier way right?

 

Thanks guys and gals.

Hi,

 

I am trying to assingn the below mentioned javascript to my custom button on VF page. But i am getting syntax error messsage. Kindly help to resolve.

 

 

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

IF(ISBLANK({!Recruiter__c.CompanyName__c}))
{
alert ("Company Name cannot be blank");
}
else{
window.open('https://c.ap1.visual.force.com/apex/sid19');
}

I am using email template in visualforce controller to send email from site.com

It is working fine and site guest user is able to send email. But when I am logged in as customer portal user in same window and then try to send email using site guest user then I dont get any row back on following line. I enable debug log and got exception message "System.QueryException: List has no rows for assignment to SObject"

 

EmailTemplate NotifyTemplate = [Select Id,Body,Subject From EmailTemplate Where DeveloperName ='Websupportrequestautoreply'];

 

any idea why?

I have a trigger on case where I send email to account team member whenever new case is created. It is working fine when I create case as standard salesforce user. but I am getting exception when I login as customer portal user and create case.

 

 I am getting following exception

 

No such column 'AccountId' on entity 'AccountTeamMember'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name.

I want to know if site guest user copy pasted or closed browser and reopened url from history. or opened same url in IE,FF, and chrome. To find out I used Userinfo.getSessionId() hoping that it will return different id in different browsers but after experiment I found it is returning same value in all browsers.

 

Any idea how I can get a unique session id? Also why it is returning same value?

I want to get 6pm of any time zone. and then convert into PST.

For example 6pm on EST will become 3PMPST. 6PM Germany time will become 9am PST.

Also I want to take care of day light saving.

 

Thanks in advance

Hi

 

I want to unlock record using apex(trigger) after record is submitted for approval. Can anybody let me know if it is possible or not? If possible then how?

 

Thanks

I have to redirect page on  a url with bookmark(#) on page. But when I redirect URL is encoded and convert # into %23 and because of that page dont scroll to the bookmark.

 

        PageReference pr=Page.SamplePage;
        pr.getParameters().put('id',obj.Id+'#'+obj.Name);
        return pr;

 

Can any body tell me how to redirect page with a bookmark on that page?

Hi All,

 

I have two portals and want to use one profile so same user can login on both portals.

 

Then I have one visualforce page and I want to display different sections based on portal. My question is that how I can find portal ID in apex so I can decide which section I need to display?

 

Thanks

I am recieving the following message when clicking on the custom button: "Problem with OnClick JavaScript button - unexpected end of input".

The issue is with the script written on !Opportunity. Amount. I am trying to write that the opportunity cannot be approved in PMI when the Amount field is BLANK.

Please help! Thanks! Beth
 
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")} 

var strStatus = '{!Opportunity.Opportunity_Status__c}'; 
switch(strStatus) { 
case 'Denied': 
alert('This opportunity cannot be approved because it has been denied.'); 
break; 
case 'Closed': 
case 'Awaiting Claim': 
case 'Claim Submitted': 
case 'Closed Expired': 
case 'Closed Won': 
case 'Closed Lost': 
alert('This opportunity cannot be updated.'); 
break; 
var strAmount = '{!Opportunity.Amount}'; 
switch(strAmount){ 
case 'Null': 
alter('This opportunity cannot be approved because no products are listed.'); 
break; 
default: 
sforce.apex.execute("CMR_DesignWebService", "ApproveToPMIDesign",{OpportunityId:'{!Opportunity.Id}'}); 
alert('Opportunity Approved in PMI system.'); 
window.location = window.location; 
break; 
}

 

Hi all,

 

I am trying to get Record Type - Picklist Entries dynamically from Apex, does anybody know a way to achieve this?

 

To be more detailed, this is what I am trying to find out:

 

In Accounts, I have a Record Type called myRecordType.

I also have an account picklist called myPicklist, containing three values, only two of which are associated with myRecordType.

I want to use Apex to find out which are the two values associated to this record type, thanks to the Record Type and Picklist Name.

 

Thanks!

  • November 11, 2013
  • Like
  • 0

I have created a picklist that displays all Email Templates in a Folder called Change Request.

 

Based on the selected Template from the picklist, i want to edit the contents of the  template before Sending the email out.

 

When I select a Template I only see a Rich text editor.

 

Can someone please point out what I am missing? Thanks!!

 

 

public class EmailTemplateSelector {

    public String selectedTemplateId { public get; public set; }
    public String templateBody { public get; public set; }        
    
    set <string> templatename = new set <string>();
    public List<SelectOption> getTemplateFolderOptions() {

        List<Folder> Folders = [Select Id, Name From Folder Where Type = 'Email'];
        system.debug(Folders.size());
    
        Set<ID> FolderIds = new Set<ID>();
        for(Folder f:Folders){
            FolderIds.add(f.Id);
        } 
        
        system.debug(FolderIds.size());
        List<SelectOption> options = new List<SelectOption>();
        List<EmailTemplate> Templates = [Select Id, Name, IsActive, Folder.Name 
                                            From EmailTemplate 
                                            Where IsActive = true
                                            And Folder.Id IN :FolderIds
                                            AND Folder.Name =: 'Change Request'
                                            ];
        
        System.debug('***Size is***' +Templates.size());
        
        for (EmailTemplate ET : Templates){
            options.add(new SelectOption(ET.Id,ET.Name));
            templatename.add(ET.Name);
            
        }
        return options;
        
        
    }
    
    public void showContent(){
  
         // query the template body based on selected template
         EmailTemplate t = [select Id,body from EmailTemplate where name =: templatename ];
            
         
         // Assign template body to "templateBody" 
         templatebody =t.body;
    }
 
}


========VisualForce Page===========

<apex:page controller="EmailTemplateSelecto>
     <apex:form >
         <apex:actionFunction name="displayTemplate" action ="{!showContent}" reRender="pan"/>
         <apex:selectList value="{!selectedTemplateId}" size="1">
             <apex:selectOptions value="{!TemplateFolderOptions}" />
         </apex:selectList>
         
         <apex:outputPanel id="pan">
             <apex:inputTextArea value="{!templatebody}" richText="true"/>
         </apex:outputPanel>

         
     </apex:form>
</apex:page>

 

  • October 28, 2013
  • Like
  • 0

I have a requirement which involves invoking a batch class through a custom button/ visualforce page.

  • August 27, 2013
  • Like
  • 0

Hi,

 

 I need to convert set of ids to string.

 

Set<id> accIdSet = new Set<Id>();

 

I need to contcatinate the string to another string.

 

after processing i need to retreive the set of ids.

 

Can someone show me some example around this.

 

 

Thanks

Hello,

I need to create a "Approve" button on my custom object "ERP" also when I click on Approve it should ask the confirmation that "Are you sure you want to Approve"?

 

Can anyone help me to create this.

 

Thanks a lot in advance.

 

Shruti

My question is, if I have input fields that are named with the same ID multiple times, what is the syntax to pass the inputted value into my APex class:

 

For example: I have the following that is in a loop for the number of financial accounts I returned in a query. So I may have ONE or MANY of these

     my loop...

                 <tr>
                    <td align="right">From Date:(mm/dd/yyyy)</td>
                    <td><apex:inputText id="fromDate" value="{!fromDate}"/></td>  
                    
                </tr>  
                <tr>
                    <td align="right">To Date:(mm/dd/yyyy)</td>
                    <td><apex:inputText id="toDate" value="{!toDate}"/></td>  
                    
                </tr> 

 end loop...

 

In other languages when I have had this situation I would have a field named fromDate, which would be an array of values, and if I wanted the 5th one from my input form it would be fromDate[5]. How is this done in Apex/VisualForce ?

 

If I were to name them uniquely like fromDate1, toDate1, fromDate2, toDate2, then I would have to create getter/setter for every one in the loop! There has to be an easier way right?

 

Thanks guys and gals.

I would like to create a custom button in the Contact detail page that when we click on it, it sends an email template capturing the information of that paricular contact.

 

How can I do this? Any code would be very much appreciate it!

 

Thanks!

Hi,

 

I am trying to assingn the below mentioned javascript to my custom button on VF page. But i am getting syntax error messsage. Kindly help to resolve.

 

 

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

IF(ISBLANK({!Recruiter__c.CompanyName__c}))
{
alert ("Company Name cannot be blank");
}
else{
window.open('https://c.ap1.visual.force.com/apex/sid19');
}

No matter where I put the excape character, i keep getting the error - No viable alternative at character '%'

 

soql +=' and Account__r.Name LIKE \' ''%\'+String.escapeSingleQuotes(accountName)+'%\'';

 Can someone please point out where am i missing a qoute?

 

Thank you.

  • June 17, 2013
  • Like
  • 0

can we sort the columns of data table on clck od table header ??

  • March 01, 2013
  • Like
  • 0

Hi to all.

I need to add an error message to a opener window. I explain it:

 

In opportunity page I have a buton wich open one window.  That window has a search functionality.

I need that if code throws an exception, it be shown in the opportunity window, not in the search one.

 

Could you help me in how doing it?

 

Thanks in advance

I would like to have a page that allows for an Account creation. When user hits Save it'll redirect them to another VF page where they can add a contact, set an activity, and create a custom object record (note). The part I can't figure out is how to provide the id of the new account record to the redirected VF page. Any help?

 

 

  • February 05, 2013
  • Like
  • 0

Hi guys,

 

I have been absolutely pulling my hair out over how to get the information I need out of the db into my trigger without putting SOQL queries within FOR loops (I'm trying to be a good boy). I'm pretty new with programming altogether so I've been having trouble getting my head around the concepts as much as the syntax; hope you can help.

 

I have custom object called BMCServiceDesk__Incident__c which has an Owner ID in it. Using this, I need to get the profile name of that user. I want to do this kind of thing, but properly using the necessary collections:

 

for (BMCServiceDesk__Incident__c inc : trigger.new){

List<User> users = [SELECT ProfileId FROM User WHERE Id = :inc.OwnerId LIMIT 1];
List<Profile> profiles = [SELECT Name FROM Profile WHERE Id = :users[0].ProfileId LIMIT 1]; inc.Team_Name__c = profiles[0].Name; }

 Here's what I have so far for the rest of the trigger:

 

public void OnBeforeInsert(BMCServiceDesk__Incident__c[] newObjects){

	Account itStaffAccount = [SELECT Id FROM Account WHERE Name = 'CMC IT Staff' LIMIT 1];
	Profile sdClientProfile = [SELECT Id FROM Profile WHERE Name = 'ServiceDesk Client' LIMIT 1];
		
	Set<Id> clientIds = new Set<Id>();
		
	for(BMCServiceDesk__Incident__c inc : newObjects){
		clientIds.add(inc.BMCServiceDesk__FKClient__c);
	}
		
	Map<Id, User> clients = new Map<Id, User>([SELECT ProfileId FROM User WHERE Id IN :clientIds]);		
	
	for(BMCServiceDesk__Incident__c inc : newObjects){
			
		if (clients.get(inc.BMCServiceDesk__FKClient__c).ProfileId != sdClientProfile.Id){
			inc.BMCServiceDesk__FKAccount__c = itStaffAccount.Id;
		}

		inc.Team_Name__c = null;
		Boolean isQueue = OwnerIdIsQueue(inc.OwnerId);
			
		if (isQueue == true){
			inc.Team_Name__c = 'Unassigned';
		}
		else {
			inc.Team_Name__c = <PROFILE NAME OF INCIDENT OWNER>;
		}
			
		system.debug('Team Name = ' + inc.Team_Name__c);
		}
	}
	
private Boolean OwnerIdIsQueue (Id ownerId){
	
	List<QueueSobject> queueIds = [SELECT QueueId FROM QueueSobject WHERE SobjectType = 'BMCServiceDesk__Incident__c'];

	for (QueueSobject q : queueIds){
		if (ownerId == q.QueueId) {
			return true;
		}
	}
	return false;
}

 If anyone could give me some pointers I'd be really grateful!

I realize that currently Workflows will not allow you to notify Account Teams from a custom object that has a lookup to Accounts. 

 

However, is there a way to do this "programatically" via Apex or some other method?  We're looking at a situation where I can have many items in my custom object all pointing to a single Account and based on some criteria we want to notify the Account Team for that given Account.

 

I've looked around and haven't found any sample code and was curious if anyone had come across this or have any suggestions.

 

Thank you!

V

Is there a way to schedule an apex job to run everyday at 5pm? 

Hello,

I'm trying to create trigger on the Opportunity object to update the child Opportunity Product records with the Opportunity Owner's department number, which is one of the fields in the User object.  I'm getting the following compile error:

 

Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<OpportunityLineItem> at line 24 column 14

 

Here's the code I have.

trigger OpportunityUpdateDept on Opportunity (after update) {
    
    for( Opportunity parent: Trigger.new)
    {
    
        List<OpportunityLineItem> children = [ SELECT Department_Number__c from 
                                               OpportunityLineItem where Opportunity.id = :parent.Id];

        list <User> currentOwner = [Select User.Department_Number__c
                                            from User
                                            where User.id = :parent.ownerid];                                                       
        
        List<OpportunityLineItem> childrenToUpdate = new List<OpportunityLineItem>();
        
        for(OpportunityLineItem thischild: children )
        {
           if( thischild.Department_Number__c !=  currentOwner[0].Department_Number__c)
           {
               thischild.Department_Number__c =  currentOwner[0].Department_Number__c;
               childrenToUpdate.add(thischild);
           }
        }
        
        if( !childrenToUpdate.isEmpty)
        {
           update childrenToUpdate;
        }
    
    }                       
}

 

I'm not exactly sure what is causing the error.  If I remove the if statement that checks if childrentToUpdate.isEmpty, then it works.  But I want to be able to skip the update if its not necessary.  Any assistance with this issue is very much appreciated.

 

Thanks!

I have a VF page inline on a custom object. It has various custom fields, and upon saving it reloads just the section that the VF page is in, not the entire page. Additionally, it reloads the entire detail page [side bar header and all], not just the VF page. Is there a way to either have the entire window refresh, or have the inline area refresh with just the VF page, and nothing else.