• jeremyy
  • NEWBIE
  • 329 Points
  • Member since 2009

  • Chatter
    Feed
  • 13
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 30
    Questions
  • 86
    Replies

I'd like to use the Metadata API (in a similar manner as Eclipse and other 3rd party IDE's) to Test and Deploy triggers and test classes that are generated based on criteria supplied by users.

 

How do external tools accomplish this? (like Eclipse)

 

Can the process be mimicked via APEX?

I cannot figure out how to reference variables from the controller initiated in the constructor.

I get Variable does not exist: opp.fname__c. However this is the name of this custom field.

Am i not calling this correctly?

 

public class MailClass {
private final Opportunity opp;
public mailClass(ApexPages.StandardController controller)
{
this.opp=(Opportunity)controller.getRecord();
}

static final string Subject='Hi ' + opp.fname__c;

 

 

 

Can someone help me with getting my test class working? What is the test class missing?

 

Here is my Class:

 

public class NICCCloneWithArtifactsController 
{
    
    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
     // add the instance for the variables being passed by id on the url
    private NI_Change_Control__c r {get;set;}
    // set the id of the record that is created -- ONLY USED BY THE TEST CLASS
    public ID newRecordId {get;set;}
    
    // initialize the controller
    public NICCCloneWithArtifactsController(ApexPages.StandardController controller) 
    { 
        // initialize the stanrdard controller
        this.controller = controller;
        // load the current record
        r = (NI_Change_Control__c)controller.getRecord(); 
    }
    
    // method called from the VF's action attribute to clone the Change Request
    public PageReference cloneWithArtifacts() 
    {
        
        // setup the save point for rollback
        Savepoint sp = Database.setSavepoint();
        NI_Change_Control__c newR;
        
        try 
        {
            
            // copy the change request - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
            r = [select Id, Priority__c, Request_Summary__c, Request_Details__c, Change_Type__c, Date_Required__c, Deployment_Group__c, Data_Change__c,
                  New_Custom_Script__c, Outage_Required__c, Manager_Reviewer__c, Peer_Reviewer__c, Developer_Compiler__c, Related_Servers__c, Related_Hosted_RFC__c, NI_Change_Owner__c 
                  from NI_Change_Control__c where id = :r.id];
            
            newR = r.clone(false);
            // SANDBOX =====================================================================
            //newR.RecordTypeId = '012P00000000G42';      // Full ID = 012P00000000G42IAE
            // PRODUCTION ==================================================================
            newR.RecordTypeId = '0126000000016TJ';        // Full ID = 0126000000016TJAAY                         
            newR.Change_Status__c = 'New';
            newR.Cloned__c = true;
            newR.Cloned_From__c = r.Id;
            newR.Cloned_w_Artifacts__c = true;
            
            insert newR;
            
            // set the id of the new po created for testing
            newRecordId = newR.id;
            
            // LOOP THROUGH ALL RELATED ARTIFACTS 
            for (NICC_Artifact__c artSource : [SELECT Id, Artifact_Name__c, Type__c, Description__c, Document_Link__c, Complete__c FROM NICC_Artifact__c WHERE NI_Change_Control__c = :r.id])
            {
                
                NICC_Artifact__c artNew = artSource.clone(false);
                artNew.NI_Change_Control__c = newR.id;
                
                insert artNew;
                
                List<Attachment> Attachments = new List<Attachment>();
                for (Attachment attach : [SELECT Body, BodyLength, ContentType, Description, Name FROM Attachment WHERE ParentId = :artSource.Id]) 
                {
                     Attachment newAttach = attach.clone(false);
                     newAttach.ParentId = artNew.id;
                     Attachments.add(newAttach);
                }
                
                insert Attachments;             
            
            }

        } 
        catch (Exception e)
        {
            // roll everything back in case of error
            Database.rollback(sp);
            ApexPages.addMessages(e);
            return null;
        }
        
        return new PageReference('/'+newR.id+'/e?retURL=%2F'+newR.id);
        
    }
    
}

 

Here is my Test Class:

@isTest
private class TestNICCCloneWithArtifactsController 
{
 
    static testMethod void testArtifactCloneController() 
    {
		
        // Creae a Change Request
        NI_Change_Control__c nicc = new NI_Change_Control__c();
        //SANDBOX ====================== nicc.RecordTypeId = '012P00000000G42';
        //nicc.RecordTypeId = '012P00000000G42';
       // PRODUCTION =================== nicc.RecordTypeId = '0126000000016TJ';
        nicc.RecordTypeId = '0126000000016TJ';
        nicc.Change_Steps__c = 'test';
        nicc.Date_Required__c = system.today();
        nicc.Request_Summary__c = 'Test';
        insert nicc;
 
        // create new Artifact record
        NICC_Artifact__c ar = new NICC_Artifact__c();
        ar.NI_Change_Control__c = nicc.Id;
        ar.Type__c = 'Customer Sign-off';
        ar.Document_Link__c = 'TEST';
        ar.Description__c = 'TEST';
        insert ar;

        // create an Attachment for the Artifact
        Attachment a = [Select Body from Attachment Limit 1];
        Attachment attach = new Attachment();
        //attach.BodyLength = 10;
        attach.Name = 'test.txt';
        attach.ParentId = ar.Id;
        attach.Body = a.Body;
        insert attach;                           
         
    }
 
}

 Here's the page code:

<apex:page standardController="NI_Change_Control__c"
     extensions="NICCCloneWithArtifactsController"
     action="{!cloneWithArtifacts}">
     <apex:pageMessages />
</apex:page>

 Any tips would be greatly appreciated!

 

I am the system admin for a non-profit and in charge of all things Salesforce. Unfortunately, I am not a developer (yet), but I need to fix a problem in our Salesforce 'backend'.

 

Right now all of our contacts automatically become "affiliated contacts" and this is problematic. As I understand it, we have an installed api package that has a trigger for this.

 

Do I need to upgrade this package? If so, how / where do I do that, and how do I avoid info being lost?

 

Thanks so much and sorry for my very limited knowledge of Salesforce!

 

Charlotte

Hi All,

 

        I need to get the zip file of all attachments from case object where case status is closed.I tried using export wizard but no hope. Any help of how to extract zip file of all attachments.

 

Thanks

Hi, I'm kind of new for SalesForce.

 

My questions is, how to enable subscriber-specific settings in a managed package?

 

For example, assume my package is going to call Facebook web services, which require the subcriber's facebook account as the license.  

 

When installing my package, the subscriber should input the user name and password of his facebook credential.   How do make this happen ? 

 

If it's impossible for the subscriber to inpu on installation, can they do that after installation?

Hi,

 

I am having difficulty immediately storing a parameter passed through a URL.

 

Here's the VF:

<input type="hidden" name="key" value="{!uniqueID}"/>

 

Here's the controller:

Public String uniqueID = System.currentPagereference().getParameters().get('q');

 

Here's the URL:

xxx.visual.force.com/apex/sendfilepage?q=xxx

 

Here's the error:

Unknown property 'sendFileController.UniqueID

 

The case is I am sending a file to amazon s3 online storage using a POST request and the URL parameter is the name of the file. This error persists until I write Public String uniqueID {get; set;} at which point I get a visualforce error saying I have two objects with the same name. It compiles when I comment out the original uniqueID. Any idea how to get around this without setting uniqueID within a new method? Or how to run a method immediately upon page loading?

 

Thanks!


Max

 

Hi, this method need to update three custom fields.
Here i need to retrieve and trim the 18 character id to 15 which i am not sure how to do for the feild
 a.Survey_Opp_Id__c = Opportunity.id;
and the for the field 

a.Survey_Dt__c update it with present date one 1( i.e next day).
And finally update the account Object.
Can anyone please help..
public void sendSurvey()
 {
 List<Account> account = new List<Account>();
 for(Account a:[SELECT a.Survey_Code__c,a.Survey_Dt__c,a.Survey_Opp_Id__c, 
                        (SELECT o.ID from OPPORTUNITIES o
                                 WHERE o.StageName='Active'
                                 AND o.Placmnt_Start_Date_Arrive__c < Last_N_days :30
                                 AND o.Placmnt_Start_Date_Arrive__c = Last_N_days :60) 
                                 FROM Account a])
              {
                                                                                   
                  if(a.Survey_Code__c != 'HF1MoArv')   
             {
               a.Survey_Code__c = 'HF1MoArv';
               //System.debug('Hello');
               system.assertEquals(a.Survey_Code__c, 'HF1MoArv');
               a.Survey_Opp_Id__c = Opportunity.id;
               //a.Survey_Dt__c = s
             } 
        
              }
 }

 

Hi all,

 

I have a trigger where the SOQL and DML statements fired are getting close to the govenor limits.

 

One of the issues is this:

    for(Opportunity o : Trigger.New) {
    	// This only concerns Opportunities being inserted
    	if(Trigger.isInsert) {
	    	// If it is the first Opportunity ensure that
	    	// Type is set to New Business.
    		account = [SELECT Id, Number_of_Opportunities__c FROM Account WHERE Id = :o.AccountId];
    		if(account.Number_of_Opportunities__c == 0) {
    			o.Type = 'New Business';
    		}
    	}
    }

 
Now, we all know it's a big no-no to have a select within a loop as the code above. My initial thought was I'd simply use this instead:

 

 

 

    for(Opportunity o : Trigger.New) {
    	// This only concerns Opportunities being inserted
    	if(Trigger.isInsert) {
	    	// If it is the first Opportunity ensure that
	    	// Type is set to New Business.
    		if(o.Account.Number_of_Opportunities__c == 0) {
    			o.Type = 'New Business';
    		}
    	}
    }

 
As you can see the select statement is now gone but this leaves me with another problem. It seems if I do that (access Number_of_Opportunities__c through o.Account it is null. Actually, it seems all fields found like that return null.

 

Any idea why?

 

Thanks.

 

/Søren Nødskov Hansen

 

Only hitting 37% test coverage.

 

Stumped as System.assert confirms that the order status is updated.

 

Can anyone spot the issue?

 

Page:

 

 

<apex:page standardController="Order__c" extensions="UpdateOrderStatus" action="{!save}">

        <apex:sectionHeader title="Auto-Running Apex Code"/>
          <apex:outputPanel >
              You tried calling Apex Code from a button.  If you see this page, something went wrong.  You should have
              been redirected back to the record you clicked the button from.
          </apex:outputPanel>


</apex:page>
		

 

Class:

 

public class UpdateOrderStatus {
	
	private final Order__c order;
	
	public UpdateOrderStatus(ApexPages.StandardController createContract){
		
		this.order = (Order__c)createContract.getRecord();
	
	}
	
	public PageReference save(){
		
		
		Order__c orderChecks = [select Accepted_Terms__c,Payment_Terms_Agreed__c from Order__c where Id=:order.Id ];
		
		if ( orderChecks.Accepted_Terms__c == true && orderChecks.Payment_Terms_Agreed__c == true){
			autoRun();
			PageReference ordPage =  new ApexPages.StandardController(order).view();
      		ordPage.setRedirect(true);
      		return ordPage;
		}
		
		else {
			PageReference ordPage =  new ApexPages.StandardController(order).view();
      		ordPage.setRedirect(true);
      		return ordPage;
		}
	
	}
	

	public void autoRun(){

		order.Order_Status__c = 'Closed - On Contract';
		update order;
	
	}
	

}

 

 

Test Class:

 

@isTest
private class testControllers {

	
	static PageReference pref;
	static UpdateOrderStatus ext;
	static Order__c orderObject;
	static OrderItems__c orderItemsObject;
	
	static {
		
		Account acc = new Account(name = 'XXX', type = 'Client');	
		insert acc;
		
				
		orderObject = new Order__c();
		orderObject.Account__c = acc.Id;
		orderObject.Order_Status__c = 'Open - Awaiting Contract';
		orderObject.Accepted_Terms__c = true;
		orderObject.Payment_Terms_Agreed__c = true;
		insert orderObject;
		
		orderItemsObject = new OrderItems__c();
		orderItemsObject.Order__c = orderObject.Id;
		orderItemsObject.Quantity__c = 1;
		orderItemsObject.Product_Type__c = 'Single';
		insert orderItemsObject;
		

	} 
	


	static testMethod void testOrderController(){
		
	test.startTest();
	ApexPages.StandardController con = new ApexPages.StandardController(orderObject);
	ext = new UpdateOrderStatus(con);
	
	if ( orderObject.Accepted_Terms__c == true && orderObject.Payment_Terms_Agreed__c == true){
			con.save();
			ext.autoRun();
			pref = con.view();
    		pref.setRedirect(true);
	}
	
	else{
			pref = con.view();
    		pref.setRedirect(true);
	}
	

    
    System.assertEquals(orderObject.Order_Status__c, 'Closed - On Contract');
    
    test.stopTest();  
	}
	
	
	
	static testMethod void testRefundController(){
		test.startTest();
		ApexPages.StandardController refundController = new ApexPages.StandardController( new Refund__c() );
		PreloadRefund preloadRefund = new PreloadRefund( refundController );
    	test.stopTest();  
	}
	
	static testMethod void testQuickContactController(){
		test.startTest();
		ApexPages.StandardController quickContactController = new ApexPages.StandardController( new Contact() );
		QuickContact quickContact = new QuickContact( quickContactController );
		test.stopTest();  
		}
}

 

 

 

hi all,

 

This is my second posting, please kindly advise me :smileysad:

 

Anyway, what I am trying to make is "math drill", which simply shows like

 

12+3 =

24-9  =

3 *4  =

 

I have code above in javascript, and I want those caluculation to be run by Apex controller,

but I can't figure out how to pass the value from javascript to Apex controller.

 

I have looked for other discussion bords no information found out:<

(this page can be simillar but no exaple on it http://community.salesforce.com/sforce/board/message?board.id=apex&thread.id=13138)

 

I really want to study this so please kindly advise me.....

 

thanks:smileysad:

Hi,

I'm attempting a deployment using the migration tool and getting this:

“My_Object__c does not have history tracking enabled.”

Yet, from the object's xml: "<enableHistory>true</enableHistory>”

The object's metadata xml was extracted without modification from a sandbox org. Is there something else required in order to enable history tracking? 
Given a field name 'Geolocation__c' of type Geolocation, the following code produces 'System.TypeException: Data type not supported':
SObject contactSob = new Contact();
System.debug(contactSob.get('Geolocation__c'));
This seems to have broken a lot of our code. Any ideas what's causing this, or a workaround?

I've been getting quite a few of these. Anyone else seeing this?

 

screen

In the stack panel, there is a number in parens after each time stamp. What does this number represent? It doesn't seem to be milliseconds or statements executed.

 

Below is a screenshot of the system log for a VF page execution. As you can see, it's reporting that the controller constructor was executed 57 times. The actual log entries don't back this up – it was executed once. Are the values in the 'Cnt' column unreliable, or am I misreading something?

 

log screen shot

The docs show the "stack" with durations listed on each line:

 

durations

 

I get something a little different:

 

different

 

Notice there are no durations. I'm currently working on performance, so it'd be helpful to have the durations. Is there some way to enable them? Thanks.

 

I'd like to run a lead through assignment rule after it has been created, using an after update trigger. The trigger below is a proof of concept, but the assignment rule does not run. I've seen other threads that indicate this should work. Can anyone confirm?

 

trigger LeadTrigger on Lead (after update) {
	List<Lead> leadsToUpdate = new List<Lead>();
	for (Lead l : Trigger.new) {
		if (!l.AutomatedAssignment__c) {
			Lead leadToUpdate = new Lead(
				Id = l.Id,
				AutomatedAssignment__c = true
			);
			Database.DMLOptions dmo = new Database.DMLOptions();
			dmo.assignmentRuleHeader.useDefaultRule = true;
			leadToUpdate.setOptions(dmo);
			leadsToUpdate.add(leadToUpdate);
		}
	}
	if (!leadsToUpdate.isEmpty()) {
		update leadsToUpdate;
	}
}

 

  • September 21, 2011
  • Like
  • 0

From a Lead or Contact, you can click the "Send an Email" button (/_ui/core/email/author/EmailAuthor...) and choose a visualforce email template. However, how does one populate the template's recipient record and relatedTo record? Are there parameters that can be passed to populate these? The org is PE and does not have Apex, so the solution must not require Apex code. 

 

Thanks

 

Jeremy

 

 

I need to override the Quote View button, but there is no View button listed on the "Buttons and Links" settings page. Is there any way to override View button for Quotes?

 

 

In Apex, how do you get a list of Opportunity stages for a specific record type?

SELECT Id FROM Lead WHERE Owner.UserType = 'PowerPartner'

Result: 

 

INVALID_FIELD: 
SELECT Id FROM Lead WHERE Owner.UserType = 'PowerPartner'
                          ^
ERROR at Row:1:Column:27
No such column 'UserType' on entity 'Name'. 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.
INVALID_FIELD: SELECT Id FROM Lead WHERE Owner.UserType = 'PowerPartner'                          ^ERROR at Row:1:Column:27No such column 'UserType' on entity 'Name'. 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.

 

What's wrong with this query?

 

 

 

UserRole in the docs has a PortalRole field. I'm working in an org w/ a Partner portal, and this field is MIA. Oddly, there are useful portal-related fields that are *not* documented, such as PortalAccountId. But no PortalRole. 

 

I've tried SoqlX (targets api v. 21) and the eclipse plugin (v 20). Neither have the PortalRole field. 

 

Anyone know if the field was deprecated? 

 

The apex:detail element seems to have a bug. If you do an inline edit and save, the hover links disappear. By hover links, I mean the links right above the row of buttons on the detail page.

 

A simple test case is to override your Account view with this page:

 

 

<apex:page standardController="Account">
<apex:form >
    <apex:detail subject="{!account.Id}" relatedList="true" inlineEdit="true" relatedListHover="true" 
        showChatter="true" title="true" />
</apex:form>
</apex:page>

I've tested on Chrome and Firefox and this happens in both. Anyone else having this problem? Is this a known bug?

 

Hi,

 

I'm about to release v1 of a managed package. Once this package is in the wild, I'll need to make bug fixes and do maintenance releases. At the same time, I will be building v2 in a separate code base / branch. 

 

I initially thought package extensions might be a way to accomplish this, but there are some issues:

 

  • If customer wants v2, they must install v1 first. This gets worse as new major releases are completed.
  • The DE org(s) for major releases after v1 would each create a new namespace prefix.
It looks like a Patch Organizization (ch. 8 of Developing Packages for Distribution) would be the best tool for this problem. Can anyone with some experience with Patch Orgs confirm this? Any additional advice or opinions are welcome and appreciated.
Jeremy

 

I'm having an issue with what I believe is VF trying to interploate JavaScript. For example, given this JavaScript embedded in a VF page:

 

 

html += "<input type='checkbox' id='plVal" + val + "' value='" 
+ field.picklistValues[val]+ "'/> " + field.picklistValues[val] + "<br/>";

 This is output by VF:

 

html += "<input id="plVal&quot; + val + &quot;" type="checkbox" value="&quot; 
+ field.picklistValues[val]+ &quot;"/> " + field.picklistValues[val] + "<br/>";

notice that VF has apparently identified the <input> which is inside a JS string. It swapped the order of the id and type attributes, and screwed some stuff up. 

 

How can I prevent this? I tried the old trick surrrounding the JS code w/ html comments (<!-- -->), but VF outputs nothing but asterisks for the JS code. 

 

Any idea how to prevent this, besides moving JS to an external file?

 

 

I'm trying out inline editing with something like this:

 

<apex:detail subject="{!account.Id}" relatedList="true" inlineEdit="true" relatedListHover="true" showChatter="true" title="true" />

I'm using a controller extension and I've overridden save() and quicksave(). When you perform an indline edit and then click save, neither of the overridden methods are being called. Is there any way to have a controller method called when saving after inline editing?

 

For quite some time now I've noticed that the System Log window does not consistently show debug logs/information. I've discovered that creating a debug monitor (system > admin > monitoring > debug logs) causes the System Log to work. However, the debug monitors only last for 20 requests, then they must be recreated, which ends up being a major pain.

 

Anyone else have this problem and know what might be causing it?

I've written a simple VF page that exports records in a CSV format using an <apex:repeat> element. I've run into the problem that VF elements can only iterate over collections with size <= 1000. This seems to be a hard limit and I can't seem to think of an alternative solution. 

 

Has anyone solved this problem? Any ideas are appreciated.

 

Jeremy

Anyone have any info (documentation, etc.) on System.UnexpectedException?

 

The apex compiler allows it to be used in a catch block, but it doesn't seem to be catchable at runtime. Any info is appreciated.

 

Jeremy

 

Creating custom exception classes doesn't seem to be documented (well, anyway), and there's some odd behavior when attempting to do so. I'm currently focusing on constructors. Given the following class:

 

 

public class MyException extends Exception{

	private final String exceptionCode;
	
	public MyException(String code) {
		exceptionCode = code;
		// initialization code
	}
}

 

 

The Apex compiler complains with: Save error: System exception constructor already defined: <Constructor>()

 

This class defines a default constructor for the typical reasons: atomic/guaranteed construction, initialization of final variables, etc. Removing the constructor makes the compiler happy. So, are constructors not allowed for classes that extend Exception, or is there some other problem here? 

 

Jeremy

Given a field name 'Geolocation__c' of type Geolocation, the following code produces 'System.TypeException: Data type not supported':
SObject contactSob = new Contact();
System.debug(contactSob.get('Geolocation__c'));
This seems to have broken a lot of our code. Any ideas what's causing this, or a workaround?

I've been getting quite a few of these. Anyone else seeing this?

 

screen

I have 2 custom objects

 

Order Line
Inventory Allocations

 

Inventory Allocation has a lookup relationship to Order Line

 

When Order Line is created then it may create inventory allocation records when inventory is available.

 

So there can be situations where a order line has no inventory allocations.

 

How can I query the order lines which does not have any inventory allocations.

 

I need to create a VF page which shows these records and process the records to create new inventory allocations.

 

thanks

I'd like to get the dates of the most recently completed activities for each of a set of contacts by using a single SOQL query.

I realize that I could fetch all completed activities for those contacts and iterate through them to find the most recent ones, but I'm wondering if it's possible to do this in a single query that only returns the data I need.

If I were writing SQL instead of SOQL, I would do something like the examples below. (I've omitted the where clauses for simplicity.)

select WhoId, Max(ActivityDate) 
from Task where ... Group By WhoId

 or less optimally,

select WhoId, 
   (select top 1 from ActivityDate from Task T2 where T1.Id = T2.Id order by ActivityDate desc)
from Task T1
where ...
Group By WhoId

 

Neither of these approaches seems to translate directly to SOQL. Is there an alternative?


So I have a visualforce page that kind of displays a to do list, and I have two objects - Items and Activities. Activities are the children of the Items, and have a few custom fields. I want to display all the existing items and their activities and then be able to create new items or activities on each item. I can't figure out how to create activities for the specific Item they're under... any help would be nice. Here's my code: 

 

Visualforce Page:

<body>
    <div id="pageBlock" class="container_12">
        <div id="Header">
            <div class="grid_12">
                <p id="title">Whiteboard</p>
                <p id="newWBItem">New Whiteboard Item</p>
            </div>
            <apex:form >
                <apex:pageBlock >
                      <apex:pageBlockButtons location="bottom" styleClass="save_button">
                          <apex:commandButton action="{!save}" value="Save" rerender="Items"/>
                      </apex:pageBlockButtons>
                      <apex:pageBlockSection showHeader="false" id="wb_item_input">
                          <apex:inputField value="{!wbitem.Name}"/>
                      </apex:pageBlockSection>
                  </apex:pageBlock>
            </apex:form>
        </div>
        <div id="Items">
        <apex:form >
        <apex:pageBlock >
            <div id="itemSpec" class="container_12">
            <apex:repeat value="{!whiteboard}" var="item" id="itemList">
                <div id="ItemHeading">
                    <div class="grid_8">
                        <apex:outputText value="{!item.Name}" id="itemName"/><br/>
                    </div>
                    <div class="grid_3">
                        <apex:commandLink value="New Activity" id="newAct"/>   |   
                        <apex:commandLink action="{!deleteItem}" value="Delete Item" id="theCommandLink">
                            <apex:param name="ItemId" value="{!item.Id}"/>
                        </apex:commandLink>
                    </div>
                </div>
                <apex:repeat value="{!item.Whiteboard_Item_Activities__r}" var="act" id="actList">
                    <div id="Item Activities">
                        <div class="grid_9">
                             <apex:outputText value="{!act.Name}" id="actSub"/><br/>
                        </div>
                        <div class="grid_3">
                            <apex:outputText value="{!act.Due_Date__c}" id="actDue"/><br/>
                        </div>
                        <div class="grid_9">
                            <apex:outputText value="{!act.Activity_Description__c}" id="actDes"/><br/>
                        </div>
                    </div>
                </apex:repeat>
                <div class="grid_12">
                <apex:pageBlock >
                      <apex:pageBlockButtons location="bottom" styleClass="save_button_act">
                          <apex:commandButton action="{!newAct}" value="Save" rerender="Items">
                              <apex:param name="ItemId" value="{!item.Id}"/>
                          </apex:commandButton>
                      </apex:pageBlockButtons>
                      <apex:pageBlockSection showHeader="false" id="wb_item_act_input">
                          <apex:inputField value="{!wbitemAct.Name}"/>
                          <apex:inputField value="{!wbitemAct.Due_Date__c}"/>
                          <apex:inputField value="{!wbitemAct.Activity_Description__c}"/>
                      </apex:pageBlockSection>
                </apex:pageBlock>
                </div>
            </apex:repeat>
            </div>
        </apex:pageBlock>
        </apex:form>
        </div>
    </div>
</body>

 

 

Controller:

public class WhiteboardCtrl {

    private List<Whiteboard_Item__c> wboard {get; private set;}

    public WhiteboardCtrl() {
        wboard = [SELECT Name, Id,
                     (SELECT Name, Due_Date__c, Activity_Description__c
                      FROM Whiteboard_Item_Activities__r ORDER BY CreatedDate)
                  FROM Whiteboard_Item__c 
                  ORDER BY CreatedDate];
    }
    
    public Whiteboard_Item__c wbitem {
        get{
            if (wbitem == null)
                wbitem = new Whiteboard_Item__c();
            return wbitem;
        }
        set;
    }
    
    public Whiteboard_Item_Activity__c wbitemAct {
        get{
            if (wbitemAct == null)
                wbitemAct = new Whiteboard_Item_Activity__c();
                
            return wbitemAct;
        }
        set;
    }
    
    public PageReference deleteItem() {
        Whiteboard_Item__c goner = [SELECT id, name from Whiteboard_Item__c where id = :ApexPages.currentpage().getparameters().get('ItemId')];
        
        try {
            delete goner;
        } catch (DmlException e) {
        }
        PageReference curPage = ApexPages.currentPage();
        curPage.setRedirect(true);
        return null;
    }
    
    public Whiteboard_Item__c[] getWhiteboard() {
        return wboard;
    }

    public PageReference save() {
        try {
            insert wbitem;
        } catch(DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
      return null;
    }

    public PageReference newAct() {
    
       Whiteboard_Item__c item = [SELECT Name, Id,
                     (SELECT Name, Due_Date__c, Activity_Description__c
                      FROM Whiteboard_Item_Activities__r ORDER BY CreatedDate)
                  FROM Whiteboard_Item__c 
                  WHERE id = :ApexPages.currentpage().getparameters().get('ItemId')
                  ORDER BY CreatedDate];
                  
        List <Whiteboard_Item_Activity__c> acts = item.Whiteboard_Item_Activities__r;
        acts.add(wbitemAct);
        try{upsert item;} catch(DMLException e) {ApexPages.addMessages(e); return null;}
        return null;

    }

}

 

I just cant figure out how to save the Activities to the right item, at least when I try to do it nothing shows up on the refresh. Maybe I'm just not showing the values correctly? Not sure. Thanks in advance

I'd like to use the Metadata API (in a similar manner as Eclipse and other 3rd party IDE's) to Test and Deploy triggers and test classes that are generated based on criteria supplied by users.

 

How do external tools accomplish this? (like Eclipse)

 

Can the process be mimicked via APEX?

I have a custom field on lead and its mapped to account. How can I make the field not editable on the account after I convert the lead into an account??

 

Thanks

I cannot figure out how to reference variables from the controller initiated in the constructor.

I get Variable does not exist: opp.fname__c. However this is the name of this custom field.

Am i not calling this correctly?

 

public class MailClass {
private final Opportunity opp;
public mailClass(ApexPages.StandardController controller)
{
this.opp=(Opportunity)controller.getRecord();
}

static final string Subject='Hi ' + opp.fname__c;

 

 

 

Can someone help me with getting my test class working? What is the test class missing?

 

Here is my Class:

 

public class NICCCloneWithArtifactsController 
{
    
    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
     // add the instance for the variables being passed by id on the url
    private NI_Change_Control__c r {get;set;}
    // set the id of the record that is created -- ONLY USED BY THE TEST CLASS
    public ID newRecordId {get;set;}
    
    // initialize the controller
    public NICCCloneWithArtifactsController(ApexPages.StandardController controller) 
    { 
        // initialize the stanrdard controller
        this.controller = controller;
        // load the current record
        r = (NI_Change_Control__c)controller.getRecord(); 
    }
    
    // method called from the VF's action attribute to clone the Change Request
    public PageReference cloneWithArtifacts() 
    {
        
        // setup the save point for rollback
        Savepoint sp = Database.setSavepoint();
        NI_Change_Control__c newR;
        
        try 
        {
            
            // copy the change request - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
            r = [select Id, Priority__c, Request_Summary__c, Request_Details__c, Change_Type__c, Date_Required__c, Deployment_Group__c, Data_Change__c,
                  New_Custom_Script__c, Outage_Required__c, Manager_Reviewer__c, Peer_Reviewer__c, Developer_Compiler__c, Related_Servers__c, Related_Hosted_RFC__c, NI_Change_Owner__c 
                  from NI_Change_Control__c where id = :r.id];
            
            newR = r.clone(false);
            // SANDBOX =====================================================================
            //newR.RecordTypeId = '012P00000000G42';      // Full ID = 012P00000000G42IAE
            // PRODUCTION ==================================================================
            newR.RecordTypeId = '0126000000016TJ';        // Full ID = 0126000000016TJAAY                         
            newR.Change_Status__c = 'New';
            newR.Cloned__c = true;
            newR.Cloned_From__c = r.Id;
            newR.Cloned_w_Artifacts__c = true;
            
            insert newR;
            
            // set the id of the new po created for testing
            newRecordId = newR.id;
            
            // LOOP THROUGH ALL RELATED ARTIFACTS 
            for (NICC_Artifact__c artSource : [SELECT Id, Artifact_Name__c, Type__c, Description__c, Document_Link__c, Complete__c FROM NICC_Artifact__c WHERE NI_Change_Control__c = :r.id])
            {
                
                NICC_Artifact__c artNew = artSource.clone(false);
                artNew.NI_Change_Control__c = newR.id;
                
                insert artNew;
                
                List<Attachment> Attachments = new List<Attachment>();
                for (Attachment attach : [SELECT Body, BodyLength, ContentType, Description, Name FROM Attachment WHERE ParentId = :artSource.Id]) 
                {
                     Attachment newAttach = attach.clone(false);
                     newAttach.ParentId = artNew.id;
                     Attachments.add(newAttach);
                }
                
                insert Attachments;             
            
            }

        } 
        catch (Exception e)
        {
            // roll everything back in case of error
            Database.rollback(sp);
            ApexPages.addMessages(e);
            return null;
        }
        
        return new PageReference('/'+newR.id+'/e?retURL=%2F'+newR.id);
        
    }
    
}

 

Here is my Test Class:

@isTest
private class TestNICCCloneWithArtifactsController 
{
 
    static testMethod void testArtifactCloneController() 
    {
		
        // Creae a Change Request
        NI_Change_Control__c nicc = new NI_Change_Control__c();
        //SANDBOX ====================== nicc.RecordTypeId = '012P00000000G42';
        //nicc.RecordTypeId = '012P00000000G42';
       // PRODUCTION =================== nicc.RecordTypeId = '0126000000016TJ';
        nicc.RecordTypeId = '0126000000016TJ';
        nicc.Change_Steps__c = 'test';
        nicc.Date_Required__c = system.today();
        nicc.Request_Summary__c = 'Test';
        insert nicc;
 
        // create new Artifact record
        NICC_Artifact__c ar = new NICC_Artifact__c();
        ar.NI_Change_Control__c = nicc.Id;
        ar.Type__c = 'Customer Sign-off';
        ar.Document_Link__c = 'TEST';
        ar.Description__c = 'TEST';
        insert ar;

        // create an Attachment for the Artifact
        Attachment a = [Select Body from Attachment Limit 1];
        Attachment attach = new Attachment();
        //attach.BodyLength = 10;
        attach.Name = 'test.txt';
        attach.ParentId = ar.Id;
        attach.Body = a.Body;
        insert attach;                           
         
    }
 
}

 Here's the page code:

<apex:page standardController="NI_Change_Control__c"
     extensions="NICCCloneWithArtifactsController"
     action="{!cloneWithArtifacts}">
     <apex:pageMessages />
</apex:page>

 Any tips would be greatly appreciated!

 

I am the system admin for a non-profit and in charge of all things Salesforce. Unfortunately, I am not a developer (yet), but I need to fix a problem in our Salesforce 'backend'.

 

Right now all of our contacts automatically become "affiliated contacts" and this is problematic. As I understand it, we have an installed api package that has a trigger for this.

 

Do I need to upgrade this package? If so, how / where do I do that, and how do I avoid info being lost?

 

Thanks so much and sorry for my very limited knowledge of Salesforce!

 

Charlotte

Hi All,

 

        I need to get the zip file of all attachments from case object where case status is closed.I tried using export wizard but no hope. Any help of how to extract zip file of all attachments.

 

Thanks

I am trying this code to assign multiple approvers to an existing approval process

 

Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();req1.

 

setComments('Submitting request for approval.');

 

req1.setObjectId(theId);

 

req1.setNextApproverIds(new Id[] {'00590000000OYw5', '00590000000OYw5'});

 

 Approval.ProcessResult result = Approval.process(req1);

 

but its giving exception that the required field missing at line

 

 Approval.ProcessResult result = Approval.process(req1);

 

Please help me out. How to assign multiple User ids as approvers to the approval process but only through apex code

 

Thanks

for (User u : Trigger.new) {

AccountShare share = new AccountShare();

share.AccountId = u.AccountId;

}

 Why is the IDE telling me that User doesn't have an AccountId field?

 

User object