function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sdavidow9sdavidow9 

Illegal Assignement from Void to String

Hi, I'm following an example I found:

http://sfdc.arrowpointe.com/2009/01/08/invoke-apex-from-a-custom-button-using-a-visualforce-page/

 

To invoke apex from a button on a page.  What I'm doing is a deep clone of a custom object (cloning related lists as well).  The cloning is working, but I can't seem to get the system to return the user to the NEWLY cloned record.  I get the error here:

 

           theClonedId = IC_util.DeepCloneClass(c);

Okay, so the quick code is that on my vf page I have a loop (I've taken out comments and debug log calls to shorten this):

 

        for (SFDC_CLass__c c:[select id, name from SFDC_Class__c where id =:theId]) {
            theClonedId = IC_util.DeepCloneClass(c);
         }

All I want to do here is call my IC_util.DeepCloneClass routine.  That's actually working.  It SHOULD return a string:

public static string DeepCloneClass(Class__c c) {
       try {

            List<Attendance__c> attendList = [select id, contact__c from Attendance__c where class__c = :c.id];//'a0A60000002d5Ip'
            Class__c newClass = new Class__c(name=c.Name + ' - clone');
              insert newClass;

            for(Attendance__c a :attendList) {
                insert new Attendance__c[]{new Attendance__c(contact__c=a.contact__c, class__c=newClass.Id)};

            }//end for

return newClass.Id;

   } //end try 

 

Any help would be great.

Best Answer chosen by Admin (Salesforce Developers) 
sdavidow9sdavidow9

So I resolved the issue by removing the IC_util class and moving the actual code routine into my page extention class.  I'm not really sure why this should change anything. 

 

The sfdc_class__c vs. class__c has to do with - man, blanking on what it's called -  how it is packaged.  I really don't know why sometimes I need sfdc_ and sometimes need to NOT have it (it was really a trial and error thing).

 

So it has something to do with going to an outside class, and your point of having sfdc_ preface may be causing the issue.  Right now I'm solving the issue by putting my routine within the same function.  Yeah, not something I can reuse and probably not the best coding practice, but working at this point.

All Answers

JeremyKraybillJeremyKraybill

What happens if you remove the "try {" wrapper around your clone method? I'm suspicious of that because it appears to not serve any function (unless you left off a catch block at the end of the method).

 

Also, probably an editing error, but your caller is dealing with an object called "SFDC_Class__c" and your callee is dealing with an object called "Class__c". I'm assuming you edited these for posting here, obviously they need to have the same type on both sides.

 

Jeremy Kraybill

Austin, TX

sdavidow9sdavidow9

So I resolved the issue by removing the IC_util class and moving the actual code routine into my page extention class.  I'm not really sure why this should change anything. 

 

The sfdc_class__c vs. class__c has to do with - man, blanking on what it's called -  how it is packaged.  I really don't know why sometimes I need sfdc_ and sometimes need to NOT have it (it was really a trial and error thing).

 

So it has something to do with going to an outside class, and your point of having sfdc_ preface may be causing the issue.  Right now I'm solving the issue by putting my routine within the same function.  Yeah, not something I can reuse and probably not the best coding practice, but working at this point.

This was selected as the best answer