• Saurabh Dhoble
  • SMARTIE
  • 678 Points
  • Member since 2012

  • Chatter
    Feed
  • 21
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 188
    Replies
I keep getting the following error, and am not sure why. The Apex class I created works in Sadbox and uploads for deployment without an issue, but it fails when I go to "Inbound Change Sents" and try to deploy the new class...

ERROR:
Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Student_Master.ApplicationMasterTrigger: execution of AfterInsert caused by: System.QueryException: List has no rows for assignment to SObject (Student_Master): []", Failure Stack Trace: "Class.App...


Hi guys I got the following error while deploying will you pleae help me here

Description: The 'knowledgecontroller' class is under “Sample Public Knowledge Base for Salesforce Knowledge” package, which is not using by us currently. But I am getting deployment error only due to this package which we can't remove/uninstall due to some dependencies.

Run Failures:
# Deploy Results:
File Name: classes/SelectEmailLeadsCtrl.cls
Full Name: SelectEmailLeadsCtrl
Action: UPDATED
Result: SUCCESS
Problem: n/a

File Name: classes/SelectEmailLeadsTest.cls
Full Name: SelectEmailLeadsTest
Action: UPDATED
Result: SUCCESS
Problem: n/a

File Name: package.xml
Full Name: package.xml
Action: UPDATED
Result: SUCCESS
Problem: n/a

# Test Results:
KnowledgeController.null line 292, column 16: No such column 'permissionsviewknowledge' on entity 'Profile'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
KnowledgeControllerTest.null line -1, column -1: Previous load of class failed: knowledgecontroller
MyProfilePageController.null line -1, column -1: Previous load of class failed: knowledgecontroller
pkb_Controller.null line -1, column -1: Previous load of class failed: knowledgecontroller
pkb_Mobile_ConfigController.null line -1, column -1: Previous load of class failed: knowledgecontroller
pkb_mobile_controller.null line -1, column -1: Previous load of class failed: knowledgecontroller
pkb_Mobile_CustomSettingModel.null line -1, column -1: Previous load of class failed: knowledgecontroller
pkb_mobile_proxy.null line -1, column -1: Previous load of class failed: knowledgecontroller
pkb_mobile_Test.null line -1, column -1: Previous load of class failed: knowledgecontroller
pkb_SecurityHandler.null line -1, column -1: Previous load of class failed: knowledgecontroller
pkb_SettingsController.null line -1, column -1: Previous load of class failed: knowledgecontroller
pkb_SiteMap.null line -1, column -1: Previous load of class failed: knowledgecontroller
pkb_Test.null line -1, column -1: Previous load of class failed: knowledgecontroller
ScheduleDeleteGaps.null line -1, column -1: Previous load of class failed: knowledgecontroller
ScheduleSendWeeklyAccountEmails.null line -1, column -1: Previous load of class failed: knowledgecontroller
SelectEmailLeadsCtrl.null line -1, column -1: Previous load of class failed: knowledgecontroller
SelectEmailLeadsTest.null line -1, column -1: Previous load of class failed: knowledgecontroller
SendWeeklyAccountEmails.null line -1, column -1: Previous load of class failed: knowledgecontroller
SendWeeklyAccountEmailsTest.null line -1, column -1: Previous load of class failed: knowledgecontroller
SiteRegisterController.null line -1, column -1: Previous load of class failed: knowledgecontroller
testCheckEmailWhitelist.null line -1, column -1: Previous load of class failed: knowledgecontroller
TriggerUtil.null line -1, column -1: Previous load of class failed: knowledgecontroller
Web2Case_Setup_Controller.null line -1, column -1: Previous load of class failed: knowledgecontroller
Good afternoon,

I'm trying to write a test class for a trigger where if there's an open Task on a record (custom object, Sales_Order__c), then the status of the record (Sales Order) = "Pending Question".  When the task is complete, then the status updates to "Ready for Review".  The trigger works fine, but I can't seem to get the test class to save:

@isTest
private class TriggerSalesOrderUpdateonTask {

static testMethod void validateTriggerSalesOrderUpdateonTask () {
List<Sales_Order__c> so = new List<Sales_Order__c> {new Sales_Order__c (
      so.name = '000001')};
        insert so;

List<task> t = new List<task> {new task(
        WhatID = Sales_Order__c[0].id,
        subject = 'test trigger',
        Status = 'Not Started')};
        insert t;

List<task> taskstoupdate = New List<task>{[select id from task where id in :t]};
    for (task tok:taskstoupdate)
    tok.Status = 'Completed';
   
    update taskstoupdate;
   


        system.assertEquals(so.Status__c, 'Sales Order Ready for Review');

    }
}


I'm receiving a Compile Error: Invalid field initializer:so.name at line 6 column 7.  Can someone take a look and see where i'm going wrong, and let me know if you need me to post my trigger on here as well.  Thanks community.
I have a custom object that has a master-detail relaionship with Opportunities. The custom object is called "Invoices". I want to prepopulate some fields in the "Invoices" record using a custom button. 

The ID of  the currency custom field on the Opportunity that I am interested in is 00N50000002UECs. I want to have the value in this currency field prepopulate to my custom field 00N50000002UECe on my custom object when I create a new record. 

I am having trouble referencing the Opportunity field in my URL so that it prepopulates the custom field on my custom object. 

My button URL code is the initlal standard URL plus &00N50000002UECe=00N50000002UECs

This results in the text value "00N50000002UECs" prepopulating in the field. How do I reference the field that is on the Opportunity that is related to the custom "Invoice" object?
Hello all.  I've recently started a new job with a marketing firm here and have been thrown into the hot seat.  I have a strong SQL and SQL Server background but have never used SOQL or anything salesforce related.  Ever.  I'm only day three into this project but I'm finding this all very challenging and frustrating.  

I am simply trying to use a UI provided by SalesForce (Enterprise Editiion) called Workbench.  This allows me to query from tables...or I guess I should call them Objects.   I am simply trying to write a query where I need to inner join two tables with some conditions.  I have spent the past day or so investigating and reading several topics online regarding this but I am not making any progress.

I truly appreciate any help or feedback you can provide!

I have two questions:

1) When I write anykind of query using Workbench and select View As Bulk CSV, it only exports my actual query into a txt file.  Is this correct?  I was hoping to query out some basic data and use it in a local copy of SQL Server.

2) Here the important one.  Listed below is the query I've tried to write in several variations withouth any luck.  I do know for a act the relationship between the tables is Opportunity.ID (parent) >> Task.WhatID (child).

If I were to do this in any SQL environment, I would simply do this:

SELECT  Task.Subject, Opportunity.CreatedDate, Opportunity.StageName
FROM  Opportunity
INNER JOIN Task ON Opportunity.Id = Task.WhatID
WHERE  (Opportunity.StageName = 'Prospecting')
AND (Opportunity.Name NOT LIKE 'ACME')

Can someone please suggest the proper SOQL syntax?

Once again, THANKS for helping!



 


Can I de-activate an Apex class directly in the production environment ? Right now I have some classes which are preventing me from deploying a change set because of some errors which I am getting them. The class is no longer being used in the production environment, so I would like to de-activate it - or do I need to do it through a change set ?

 

If I de-activate the classes in question will that be good enough for me to then have a successful change set deployment ?

 

Thank you for your help.

  • April 24, 2013
  • Like
  • 0

Hi,

 

This may seem like a simple question but one I thought I'd ask to confirm all the same.

- if 2 records are inserted to an object within the same second,  if ordering the results of a SOQL query by createddate will Salesforce return the correct order in which they were inserted (if miliseconds can be the differentiator).

 

The reason I ask is I note the createddate field is of type datetime and it states on the following

http://www.salesforce.com/us/developer/docs/api/Content/primitive_data_types.htm#i1435039

Regular dateTime fields are full timestamps with a precision of one second. therefore I'm assuming it may not order the results correclty as per when they were inserted if they were created within the same second.

 

Thanks in advance for any further information on this.

BACKGROUND

As you know, there is no ‘SELECT *’ with Apex. You have to specify every field.

When you do a clone, you have to select all the fields.

If someone adds a field after you write the ‘clone’ program, you have to update the clone program with the field changes. PITA and not reliable.

 

OR

 

Another way is to use the ‘Describe’, get a list of fields, and assemble the SOQL statement.

That is what I did.

 

TESTING

As I was testing the program that creates the dynamic SOQL, I let it run, and grabbed the SOQL from the Developer Console. (system.debug).

I then pasted this into the SOQL window in Developer Console.

 

AND THE PROBLEM IS…

Fields that show in the ‘Account’  (Setup | Customize |Accounts | Fields), these same fields are in the ‘Describe’. Some are NOT in the WSDL, and will not SELECT when doing a SOQL statement.

 

That does not sound normal to me.  Any ideas???

 

Thanks in advance.

  • April 23, 2013
  • Like
  • 0

I would like to use the values of a multi-value field of one record the select options of another record's multi-select picklist. I am currently doing something very similar to this with a query which is returning field values from multiple records in a relationship. 

 

Here is my current code which pulls the value from a single field from several records : 

public class MycontrollerSFDCBETA2b
{
private final Contract_Overview__c contract;
public String rightOptionsHidden { get; set; }
public String leftOptionsHidden { get; set; }
public String selectedMulPickKeyTech{get;set;} 
public string names{get;set;}
public string accountid{get;set;}
public String message { get; set; }
public List<SelectOption> options { get; set; }
public List<SelectOption> selectedSubs2 { get; set; }
    
    public MycontrollerSFDCBETA2b(apexpages.standardcontroller controller)
        {
        this.contract = (Contract_Overview__c) controller.getRecord();
        }

    public pageReference  execute()
        {
        return null;
        }

    public list<selectoption> getitems()
        {
        accountid=contract.Account__c;
        
        selectedMulPickKeyTech=contract.Subsidiaries_On_Contract__c;
        selectedMulPickKeyTech=selectedMulPickKeyTech.replace('[','');                
        selectedMulPickKeyTech=selectedMulPickKeyTech.replace(']','');

        String[] selectedvalues = selectedMulPickKeyTech.split(',');
        selectedSubs2 = new list<SelectOption>();
        for (String selectedvalue: selectedvalues) 
            {
            selectedSubs2.add(new SelectOption(selectedvalue,selectedvalue));
            }
    
        List<selectoption> options= new list<selectoption>();
            if(accountid != null)
            {
            account a =[select name , (select name from Subsidiaries_and_Brands__r) from account where id =:accountid];
                for(SubsidiariesAndBrands__c s : a.Subsidiaries_and_Brands__r)
                    {
                    options.add(new SelectOption(s.name,s.name));
                    }
            }
            else
            options.add(new SelectOption('None','None'));
            return options;
        }
    
    public void save()
        {
        message = null ;       
        Boolean first = true;
           for ( SelectOption so : selectedSubs2 ) 
            {
                if (first) 
                    {
                    message = message ;
                    }
                    message = message + ', ' + so.getValue() ;
                    first = false;
            }        
                message = message.removeStart('null, ');
                message = message.normalizeSpace();
                message = '['+message+']';
                contract.Subsidiaries_On_Contract__c=message;
        
        update contract;
                       
        }
}

 

From that code I am using !items as the select options of a picklist on VF. 

 

I'd like to accomplish the same thing by querying a single record's multi-value field. I have a very VERY generalized idea how to accomplish it. I think I need to take some kind of approach like this : 

String[] picklistlines =new String[]{};
String selectedMulPickKeyTech{get;set;} 

public string contractid{get;set;}

public list<selectoption> getitems()
            {
            contractid=contract.Contract_Title__c;

contract = [SELECT Subsidiaries_On_Contract__c FROM Contract_Overview__c where Contract_Overview__c.id=:contractid];

selectedMulPickKeyTech=contract.Subsidiaries_On_Contract__c;


					
picklistlines = selectedMulPickKeyTech.split('\n');

 

But I don't know how to properly build the list with the For statement. I also don't think that query will work properly.

 

If you can give me any help I would really appreciate it. I feel like I'm very close to the solution here.

 

Thank you very much.



  • April 22, 2013
  • Like
  • 0

Hi devs,

 

Can anybody give me a solution. I have the following code

 

sObject[] upserts = new o2bc__Item__c[1];

o2bc__Item__c upsertAccount = new o2bc__Item__c();

 upsertAccount.RecordType.Name ="Product/Parts";  -- Here i got obj reference issue - Can anyone tell how to populate        value for this
upsertAccount.Name = "SFG TEST";
upsertAccount.Rental__c = 150.00;
upsertAccount.Sell_Price__c = 250.00;
upsertAccount.Pricing__c = "Flat";
upsertAccount.Bill_Cycle__c = "Daily";

upserts[0] = upsertAccount;



try
{
int i = 0;
SaveResult[] upsertResults = SFService.create(upserts);
foreach (SaveResult result in upsertResults)
{

if (result.success)
{

MessageBox.Show("Updated Success");


}

Is this possible?

When a task is created from a contact, Phone number is pre-populated with the contact's phone. When a task is created from an account, Phone number is pre-populated with the account's phone.

 

Any help is greately appreciated!! Thank you!

I have created a VF page that has a custom button as a part of it. When I click the custom button, I want the new page to open in a new window. When I am logged in, this works. When other uses are logged in and the button is clicked, it opens the new page like it is embedded in the VF page.

 

Here is my code:

 

<apex:page standardcontroller="Wire_Center__c" tabStyle="Sites__c" extensions="RFMDU">
    <apex:pageBlock >
                <apex:pageBlockTable value="{!Sites}" var="zip" width="100%" columns="5">
                <apex:column id="c7">
                    <apex:form >
                    <apex:commandButton value="Assign" onclick="javascript&colon;openPopUpWindow;return false" action="/a1E/e?CF00NC0000005bqW8={!zip.name}&CF00NC0000005bqW8_lkid={!zip.id}"/>
                    </apex:form>
                </apex:column>                
                <apex:column id="c5" headerValue="MDU">
                    <apex:outputLink value="/{!zip.Id}" target="_top">{!zip.Name}</apex:outputLink>
                </apex:column>
                    <apex:column id="c4" headerValue="Last Resweep">
                        <apex:outputField value="{!zip.Date_of_Last_Resweep__c}"/>
                </apex:column>
                    <apex:column id="c3" headerValue="Current Penetration">
                        <apex:outputField value="{!zip.Current_Penetration__c}"/>  
                </apex:column>
                    <apex:column id="c2" headerValue="Non-Video Doors">
                        <apex:outputField value="{!zip.Non_Video_Doors__c}"/>                      
                </apex:column>          
                </apex:pageBlockTable> 
    </apex:pageBlock>
</apex:page>

Any thoughts?

 

Thanks in advance,

 

Matt

Hi,

 

The following is my code...which has a problem.

 

<apex:page>

    <apex:form id="theForm">

         <apex:selectRadio id="theRadio" onchange="test()">

               <apex:selectOption itemValue="india" itemLabel="India" />
               <apex:selectOption itemValue="ap" itemLabel="AP" />

         </apex:selectRadio>

         <script>

                  function test()

                  {

                          alert('you selected :'+'document.getElementById('{!$component.theForm.theRadio}').value);

                  }

         </script>

   </apex:form>

</apex:page>

 

 

   my doubt is why it was not trigger means the alert is not working..................

  please can any one tell me the reason and solution also.

 

Thanks

Srikanth

        

I have created a clone case option which clones everything in the case, however my Team is asking for a field in the visual force page to set the case owner so that they dont have to open the cloned case, they can just assign it to the person or queue.... Here is what I have so far:

 

<apex:page standardController="Case"
extensions="CaseClone"
action="{!testthis}">
<apex:pageBlock title="Hello {!$User.FirstName}!"><br />


Your support case has been cloned!<br /><br />
<i><b>Warning! Do not hit "refresh" on your browser or your case will be cloned AGAIN</b></i><br />
<br /><br />
<table cellpadding="10">
<tr>
<td>Original Case Number:</td>
<td>{!CaseNumberOld}</td>
<td><a href="/{!CaseIdOld}">Go to this case...</a></td></tr>
<tr>
<td>New Case Number:</td>
<td>{!CaseNumberNew}</td>
<td> <a href="/{!CaseIdNew}">Go to this case...</a>:</td>
</tr>
</table>
<br/><br />
</apex:pageBlock>
</apex:page>

 

The issue is that the action taken is what clones the case, and if I were to setup something to input the case owner and set it, it would have to go before the action wouldnt it?  I was thinking it could just modify the record after it is created but to do that from VF I dont know.  

 

Any help would be appreciated....

 

Thanks

Hi,

 

I have 'message'  variable in my controller.  onComplete event of actionFucntion,I want  updated value of message  variable.

 

Could you please tell me how to do this?

 

Thanks in advance.

Dipak

How can I use an datepicker of apex in my jquery mobile page. At the moment my code is looking like this.

 

<br/>
		<label>Enddatum</label>
    	<apex:inputField value="{!ZeiterfassungsListe.Enddatum__c}"/>
    	
    	<br/>
		<label>Öffentliche Notizen</label>
    	<apex:inputField value="{!ZeiterfassungsListe.Oeffentliche_Notizen__c}"/>
 

 

 

On the result i get an empty field without any selection of dates. Under the field it shows the date of today.. Crazy...

I want to get the normal datepicker of salesforce.

Any solution???

 

 

I've looked around for a couple hours trying to figure this out but have been unable.  I am trying to pass a variable from javascript to my VF extension. The exact variable is 'sforce.console.isInConsole()' to determine if my users are accessing the page via the Console or not.  Below is the javascript I have included within my VF page:

 

<script type="text/javascript" >
    document.getElementById('{!$Component.Console}').value = sforce.console.isInConsole();
</script>

 

Below is the inputHidden field:

<apex:inputHidden id="Console" value="{!ConsoleVal}" />

 

Lastly, below is what I have included within my APEX class:

public String ConsoleVal {get; set;}

 

 

All resources I have found lead me to believe that this should work.  However, the ConsoleVal variable is null when I look at the debug logs, so there is a disconnect...  What am I missing?

I have a use case where I need to do some string substitution on a string that has brace characters {}.  What is the proper way to escape the braces to make this test pass?

 

    public static testMethod void StringFormatFailsWithBraces()
    {
        List<string> substitutions = new List<String>();
        substitutions.add('world');
        string result = string.format('{hello {0}}', substitutions);
        System.assertEquals('{hello world}', result);
    }

 

Below is the very interesting exception which leads to demo.icu-project.org, which doesn't tell me any information.


System.StringException: All argument identifiers have to be either non-negative numbers or strings following the pattern ([:ID_Start:] [:ID_Continue:]*).
For more details on these unicode sets, visit http://demo.icu-project.org/icu-bin/ubrowse

 

Thanks!

 

Matt

I am trying to build a publicly accessible web page from a custom object and allow the user to select a subset of data.  For example, one field is a picklist in Salesforce and I want them to be able to show only those items that have a certain value selected.  I have created a page that shows the list of items, but I have no idea where to start to create the search form to filter that data.  Can anyone help me get started?

 

Here is the page I want to move to Visualforce - it is currently a PHP-based page built using the API - http://www.mvista.com/boards.php.

Folks,

I'm running into an issue putting hyperlinks inside a repeat object - please see below VF code -

<apex:outputPanel id="opnlSearchResult">
     <apex:repeat value="{!searchResult}" var="contact">
          <a href="#">
               <h1>{!contact.Name}</h1>
                <p>{!contact.Id}</p>
           </a>
      </apex:repeat>
</apex:outputPanel>

{!searchResult} is a list of type Contact.
I'm expecting this to generate a repeat of the following HTML :-

<a href="#">
   <h1>Name1</h1>
   <p>Id1</p>
</a>
<a href="#">
   <h1>Name2</h1>
   <p>Id2</p>
</a>

Instead, I'm getting -

<a href="#"></a>
<h1><a href="#">Name1</a></h1>
<p>Id1</p>

Basically, I want the header & paragraph to appear **inside** the hyperlink - this is required so they render correctly on mobile html5 pages. But Visualforce is somehow distorting the HTML.

Please help !!

I'm trying to setup automated salesforce deployment for our project, using ANT & the salesforce migration tool.Problem is, when I deploy custom objects, it doesn't seem to be overwriting the fields.

For e.g., if I have a field "Overview" on a custom object, and I remove it from the XML file definition, the ANT deployment somehow leaves the field on the object in salesforce after deployment.

 

I tried putting in the destructiveChanges.xml file which works, but I cannot put each and every field that we are changing into the destructiveChanges file. I'm hoping that there is a better way to do this.

 

Any help is appreciated.

Hi,

 

I am trying to show the standard contact edit page without a sidebar. Is it possible to turn it off ?

The reason is I want to show the "Edit Contact" page in a jQuery popup. But having the sidebar and header takes up too much screen real estate.

 

Any ideas would be helpful.

 

Thanks.

Hello Team,

Can any of you tell me if we can filter Picklist by recordType through API? If so could someone please provide some sample code on how to do this.


Thanks
  • May 21, 2014
  • Like
  • 0
Hi,

  I am not able to check --none-- default value that is displayed in select list using javascript. Please suggest me how to validate

   If selectlist display --none-- it must alert a message to user I am calling javascipt on a button click

  Below highlighted is a selectlist code

Visual Force
---------------

<script type="text/javascript">
function Opportunity_Validation()
{
  var val   = document.getElementById('{!$Component.RenewalForm.configblock.configsecblock.confignewopp.newopp}').value; 
  var oval  = document.getElementById('{!$Component.RenewalForm.configblock.configsecblock.configopport.existopp}').value; 
  var edate = document.getElementById('{!$Component.RenewalForm.configblock.configsecblock.configexpiredate.expredate}').value; 
  var eterm = document.getElementById('{!$Component.RenewalForm.configblock.configsecblock.configexpiredate.expterms}').value; 
                                   
 
   if ( val == '' && oval == '') {
    alert('Enter Opportunity Details');
    return false;
    }
   else if ( val != '' && oval != '') {
     alert('Enter either existing opportunity or new opporutnity');
     return false;
     }
   else if ( edate == '' ) {
     alert('Enter Expire Date');
     return false;
     }
   else if ( eterm == 'none' ) {
     alert('Select Expite Term');
     return false;

     } 
    return true;
  }
</script>




<apex:form id="RenewalForm">
<apex:pageBlock id="configblock">
<apex:pageBlockSection title="Configuration Option" columns="2" id="configsecblock">

  <apex:pageBlockSectionItem id="configexpire">
   <apex:outputLabel value="Expiry Term:" for="expireterm"/>
   <apex:selectList value="{!ExpireTerms}" multiselect="false" size="1" id="expterms">
                <apex:selectOption itemValue="0" itemLabel="--none--" id="exptermsnon"/>
                <apex:selectOption itemValue="1" itemLabel="1 Year"/>
                <apex:selectOption itemValue="3" itemLabel="3 Year"/>
                <apex:selectOption itemValue="5" itemLabel="5 Year"/>
    </apex:selectList>
   </apex:pageBlockSectionItem>

Thanks
Sudhir
I've been notified almost everyday, that my teams daily API limit is being exceeded, Salesforce cannot give me an answer of why, and the 7 day report does not match Salesforce's records; I have been dealing with this for over two weeks now, and essentially has caused our business to come to a halt. We can't operate in an optimal fashion and our numbers have drecreased becasue of this. Its essentially become a business stopping issue and I don't believe my request is very difficult.

Very simply, all I'm only looking to figure out 2 things: 1) See my teams daily API Average  2) The source that is eating up all of our API Calls

I can't stress enough how easy of a request this seems to be and Salesforce has been of no help at all. Our SF Account Exec has been awesome and hustling to try to get an answer, but to no avail. No one else internaly is willing to give us an answer, so I ask the community... Any ideas? Thanks! 

I have a VFp , which open another VFP as a popup, after the pop is closed, i want the parent page that opened the popup to be refreshed. 

My code/javscript  closes the VFP popup but it doesnt reload the parent page. I have to manually reload the parent page to see the updated record.

Note:  The reason i am using window.open is becuase i want users to have the ability to scroll through the parent window. 

Any suggestions????


**********************************************************************************************************************
VFP1

<script type="text/javascript">
function OpenVfpage(){
window.open('/apex/SendEmailPage?id={!recordId}', '_blank','scrollbars=yes,width=600,height=800,resizable=no,toolbar=0,location=0,menubar=0');
}
</script>

<apex:commandButton value="Send Email" id="email" onclick="javascript:OpenVfpage();"/>

**********************************************************************************************************************


VFP2

<script language="javascript" type="text/javascript">
function closeVFP() {

if("{!$Request.success}" == "true") {
parent.window.close();
window.close();
        
}
</script>

<apex:commandButton id="saveBtn" value="Send" action="{!sendEmail}" onComplete="javascript:closeVFP();"/>


**********************************************************************************************************************
Controller

public PageReference sendEmail(){
// logic to send the email
return new PageReference ('javascript:window.close()');

}
Hi guys please reply to my question as soon as possible.

1.Our organization has installed unmanaged package 2 years back with some licenses.
2.They are not using this package from past 1 year & didn't renewal the license.
3.Now we are getting deployment errors with that package which has some dependencies.
4.Finally I just want to know how to uninstall that package in production as we can't do any changes to classes in production

We have a repository that holds text for email as pure HTML.  I have some code to send email with this text as the html body and that works well and is fairly simple.  We can also add attachments.

What I haven't figured out how to do is embed and image in the email.  From what I understand, the email would have in it a "cid:" URL like --
 

<img width="128" height="128" id="Picture_x0020_1" src="cid:image001.png@01CF6E9E.C4B30B30">
I could compose a tag like that no problem.  The issue is the cid: for the image.  I know how to add attachments.  And I know you can set the inline flag to true or false.  What I can't see a way to do is set the id for an attachment I'm including (or get back an ID after attaching it) so I can then put that content id (cid:) in the URL in the HTML body.

It may be that the email and attachment classes in Apex are just not deep enough to perform this task.  But if anyone know's a way to do it, feel free to post suggestions.




I

I have a custom Object to track registrations against an Opportunity in Salesforce. I created a script so that clicking a button would change the stage of the Opportunity and then go through each Registration and change the status if it was Pending.
When I test it on an Opportunity with 3 registrations, it seems to work every time. When I use it on an Opportunity with 7 registrations, it is changing registrations that it shouldn't be.
I store the conditions back to the Registration and it looks as though it should be ignoring the record, but it gets updated.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} //Required for SalesForce connection 

//Make sure not entering by mistake 
input_box = confirm ("Are you sure you want to update the workshop to Attended?") 

if (input_box==true) 

{ 
 var url = parent.location.href; //string for the URL of the current page 
 //Set up the connection and grab the current Opportunity ID 
 var conn; 
 conn = sforce.connection; 
 var opp = "{!Opportunity.Id}"; 
 var oppname= "{!Opportunity.Name}"; 

 //Get the Registration ID's for all Registrants to this Opportunity 
 var qr = conn.query("Select Registration__c.Id, Registration__c.Workshop_Cancelled__c, Registration__c.Payment_Status__c, Registration__c.Name from Registration__c where Opportunity_del__c ='" + opp + "'" ); 

 var reg = [ ]; 
 var rstat = [ ]; 
 var pstat = [ ]; 
 var paystat1 = "ignore"; // set the default action for payment status 
 var regstat1 = "ignore"; // set the default action for registration status 



 //Figure out how many Registrations there are 
 var records = qr.getArray("records"); 
 var length = records.length 

 //Build an array of registration ID's and status 
 for (var i = 0;i<length;i++) { 
 reg[i] = records[i].get("Id"); 
 rstat[i] = records[i].get("Workshop_Cancelled__c"); 
 } 

 //Build a message to display the Id's 
 //var message = "The Reg's for Opportunity " + opp + " are: "; 

 //for (var i = 0;i<length;i++) { 
 //message = message + " " + reg[i] + " " + rstat[i]; 
 //} 

 //Display the message 
 //alert(message); 

 //Update the Stage of the Opportunity to show Closed - Won 
 var _Opportunity = new sforce.SObject("Opportunity"); //create an sObject for an object - here we are using opportunity but it could be anything 
 _Opportunity.Id = opp; //id should be gathered from a query or something earlier in the script - you'll need the id of the record you want to update though 
 _Opportunity.StageName = "Closed Won"; //you can hard code a value or pass something dynamically (can be any field) - here we are hard coding an update to the opportunity stage 
 var updateOpportunity= sforce.connection.update([_Opportunity]); //actually perform the update to the record 

 //check for success 
 if (updateOpportunity[0].getBoolean("success")) { //check that the update was successful 
 alert("Updated account: "+updateOpportunity[0].id); //alert success notification 
 } else { //otherwise unsuccessful 
 alert("API error: "+updateOpportunity[0]); //alert response from update attempt 
 } 

 if (length > 0) { 
 //Update each of the registrations to update Pending to Attended and ignore the other statuses 
 var _Registration = new sforce.SObject("Registration__c"); //create an sObject for an object - here we are using opportunity but it could be anything 
 var regstat; 

 for (var i = 0;i<length;i++) {//process each registration 
 // get the values from the current registration record 
 _Registration.Id = reg[i]; // get the record id for the update 

 //regstat = rstat[i]; // get the value of Registration status for the current registration 
 _Registration.regstat__c = rstat[i]; // store the initial registration status for update to track what happened 

 regstat1 = "ignore"; // reset the default action each pass 

 //Build a message to display the Id's 
 //var message = "The values for the reg are: \n"; 
 //message = message + " " + reg[i] + " " + rstat[i] + "\n"; 
 //Display the message 
 //alert(message); 

 if (rstat[i] == "Pending"){ // If the registration status is Pending , set to process 
 regstat1 = "process"; 
 _Registration.Workshop_Cancelled__c="Attended"; 
 } 
 _Registration.regstat1__c = regstat1; // Update the holder to show value after test 

 var updateRegistration= sforce.connection.update([_Registration]); //actually perform the update to the record 
 } 

 //check for success 
 if (updateRegistration[0].getBoolean("success")) { //check that the update was successful 
 alert("Updated registration: "+updateRegistration[0].id); //alert success notification 
 } else { //otherwise unsuccessful 
 alert("API error: "+updateRegistration[0]); //alert response from update attempt 
 } 
 } 
 alert("The process has completed"); 
 parent.location.href = url; //refresh the page 
}

If the Registration status is Pending, it should be changed to Attended. There is one registration in the 7 that has a status of Cancelled. The values that get stored back show that it should be ignored, but it is being changed to Attended.

Note... the registration status field is Workshop_Cancelled__c

I also wondered if there is a way to put this in an array and then post all seven updates back at once, as I believe I am handling them one at a time... could this be part of the problem?

Thanks,

...Dave






We want to refresh our sandbox and the biggest thing we are worried about losing is all of our code that we have on sandbox but is not yet on production. Will that be affected? What if we have a page on production and one with changes on sandbox? Will be lose the changes on sandbox? What if we have a page on sandbox that isn't on production? Will be lose that page?

thanks,
Hi,

I'm trying to create a roll-up summary trigger for contacts to account. However, I get the following error:

Incompatible key type Schema.SObjectField for MAP<Id,Account>

Can someone help me with this? Here's my code:

trigger UpdateAccountAfterContactInsert on Contact (after insert, after update, after delete) {

    //unique Account object Ids
    private Set<Id> accountIdSet = new Set <Id>();
   
    //hold list of Account Record to be updated
    private List<Account> accountListUpdatable = new List<Account>();
   
    //when insert & update the Contact
    if(trigger.isInsert || trigger.isUpdate){
       
        for(Contact c: Trigger.new){
            accountIdSet.add(c.AccountId);
        }
    }
    //when update & delete the Contact
    if (Trigger.isUpdate || Trigger.isDelete){
        for(Contact c: Trigger.old){
            AccountIdSet.add(c.AccountId);
        }
    }
    //select the Account list
    Map<Id, Account> accountMap = new Map<ID, Account> ([Select Id from Account WHERE ID IN: accountIds]);
   
    for(Account a: [Select ID,(Select ID FROM Contacts)from Account WHERE ID IN:accountIds]){
       
        accountMap.get(account.ID) = a.Contacts.size();//assigning Size
        accountListUpdatable.add(accountMap.get(account.ID));
    }
    if(accountListUpdatable != NULL && accountListUpdatable.size()>0)
        UPDATE accountListUpdatable;
}

Hello All, 

I recently designed a trigger to update a Goals/Forecast custom object I built called Financial_Planning__c.  Basically, on the "before update" action of the object, the trigger goes out and finds all the Closed Won opportunities for that division and updates a field on the Financial_Planning__c object.

<pre>
trigger FinancialPlanningTrigger on Financial_Planning__c (before update) {

    List<Date> dtStart =  new List<Date>();
    List<Date> dtEnd =  new List<Date>();
    List<String> strSBU =  new List<String>();
    Double fpAmount = 0 ;
String strname;

      for(Financial_Planning__c fp : trigger.new){
      dtStart.add(fp.period_start_date__c);
      dtEnd.add(fp.period_End_date__c);
      strSBU.add(fp.Division__c);
      strname = fp.division__c + ' - (' + fp.Revenue_Type__c + ')';
    }
   
List<aggregateResult> fpresults = [select Sum(amount) Total from Opportunity
               where IsWon=True
               And Contract_Start_Date__c >= :dtStart
               And Contract_Start_Date__c <= :dtEnd
               And SBU__C in :strSBU];

for (AggregateResult ar : fpresults )  {
  
    fpAmount = (Double)ar.get('Total');
}
   
      for(Financial_Planning__c fp : trigger.new){
    fp.Realized_Revenue_Actual__c =  fpamount;
    fp.name = strname; // field on which Task count and event count needs to be updated
    }
   
}
</pre>

Based on some info I heard at a developers group, I want to take the code out of the trigger and put it in a class, then have the trigger call the class?  How would I do that?  I just figured out how to create a trigger, and have not really mastered classes yet.
I keep getting the following error, and am not sure why. The Apex class I created works in Sadbox and uploads for deployment without an issue, but it fails when I go to "Inbound Change Sents" and try to deploy the new class...

ERROR:
Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Student_Master.ApplicationMasterTrigger: execution of AfterInsert caused by: System.QueryException: List has no rows for assignment to SObject (Student_Master): []", Failure Stack Trace: "Class.App...


I use it all the time,

 

BUT WHY.....

 

Why declare a method to return type PageReference and then return NULL.....

 

Sorry for the newb question.........