+ Start a Discussion
nwingnwing 

"File only saved locally, not to server" warning, but no errors. Save Apex To Server

The only error I am getting on the below is that it says "File only saved locally, not to server" in the Warnings section, and of course it is not showing up in the ui.
 
I am sure this is something simple, but I have not found it yet.  Any help would be greatly appreciated.
 
Thanks,
 
 
Code:
trigger SiteLeaseEndDate on Site_Lease_Contract__c (after update) {
 private Site_Lease_Contract__c[] newSiteLeaseEndDate = Trigger.new;
 Double Months = newSiteLeaseEndDate[0].Lease_Term_In_Months__c;
 Double y = Months;
 Integer x = y.intvalue();
 newSiteLeaseEndDate[0].End_Date_2__c = newSiteLeaseEndDate[0].Start_Date__c.addMonths(x);
}

 
JonPJonP
If that's really the only message in the Problems tab, just try right-clicking on the file and selecting Force.com > Save to Server.  That might make it go away.

However, you may want to make the following changes to your code anyway:

Syntax issues:
- Remove "private" in line two.  "newSiteLeaseEndDate" is a local variable, scoped to the trigger body, so it can't be accessed by any other class anyway.  (The "private" keyword may be illegal here, in which case this might be the root cause of your warning message.)

Logical issues:
- Your trigger will only process 1 out of n records in Trigger.new[].  If you trigger fires on a batch of more than one Site_Lease_Contract__c (say, on a mass update via the API) only the first Site_Lease_Contract__c.End_Date_2__c field will be set.

- Unless Site_Lease_Contract__c is a required field, you may want to check that Lease_Term_In_Months__c is not null before calling its intValue() method.

Style issues:
You don't need the variables "y" or "x".  You could write it in one line, but you keep the readability with two:
Integer months = newSiteLeaseEndDate[0].Lease_Term_In_Months__c.intvalue();
newSiteLeaseEndDate[0].End_Date_2__c = newSiteLeaseEndDate[0].Start_Date__c.addMonths( months );


nwingnwing

 

Thank you very much for your help.  I went through everything, and changed the code as below as well as tried the save to server option, but nothing seemed to change.  I was able to save just the first and last line of the trigger to the server system, but once I put the rest of it in there no further updates get loaded....

I am trying to get over the hump here as far as experience in this environment goes, so I am not sure where to look next, but anything you have helps.

thanks,

 

Code:
trigger SiteLeaseEnd on Site_Lease_Contract__c (after update, after insert) {
 Site_Lease_Contract__c[] newSiteLeaseEndDate = Trigger.new;
    Integer mths = newSiteLeaseEndDate[0].Lease_Term_In_Months__c.intvalue();
    newSiteLeaseEndDate[0].End_Date_2__c = newSiteLeaseEndDate[0].Start_Date__c.addMonths( mths );

}


 

JonPJonP
In Eclipse's Problems View tab, do you see anything besides the warning, i.e. any errors?  Could you post a screenshot?
nwingnwing

No errors, just warnings... on this particular code anyway.  (how do you paste an image in this?)  I do not have an available server to load it onto.

Do I need to run a test on a trigger?  It will upload the trigger definition, but not the code inside once that is added. 

I am walking through apex step by step to see if I can dig this issue up, but no luck so far.



JonPJonP
Is your project connected to a Sandbox or Developer Edition organization?  Or to production?

(It is highly recommended NOT to create Force.com projects against production.  If your project is created against a production organization, all code coverage requirements for deploying to production apply every time you save a file.)
nwingnwing
 
We have a 'legacy' production sysem that we use for testing purposes......a two user job just like dev edition, but otherwise enterprise/production.
 
I was not getting the '0% tested' errors, so I assumed that wasn't the issue.....
 
thanks!
 
 
tino2008tino2008

I'm dealing since last week with the same problem.
I'm not happy with this one.

 

Neither its possible to remove unused and invalid old classes which also causes the problem on the live environment of salesforce.

 

Hope you allready found a solution and can help me out with this one because its a pain in the ass.
No help, no support.

 

Regards,
Valentino Rijhen



 

sparktestsparktest

the thing to check is......

 

make sure you select both class and trigger at the same time when you 'save to server'. 

nuked planetnuked planet

Old post but I just encountered this exact issue. Bizarre issue was I had one project working fine, the other not.

A quick look at the Eclipse Project Properties->Builders uncovered a difference.

 

The broken one was missing the definition for the "Force.com Online Builder" - but how to add it in?

Rather than battle with the Eclipse IDE GUI I decided to look at the Eclipse Project files(i.e the .project files inside each workspace project directory)

 

Working .project file:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>working@projectname</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>com.salesforce.ide.builder.online</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.salesforce.ide.builder.default</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>com.salesforce.ide.nature.default</nature>
        <nature>com.salesforce.ide.nature.online</nature>
    </natures>
</projectDescription>

 

File Saved Locally Only Issue .project file:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>broken@projectname</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>com.salesforce.ide.builder.default</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>com.salesforce.ide.nature.default</nature>
    </natures>
</projectDescription>

 

Spot the difference? :-)

A quick copy'n'paste effort later and a restart of Eclipse.... voila files now save server side.

 

Hope this helps anyone in the future.

 

 

nuked planet

FedeMFedeM

The problem I had with this is that there was already a trigger with the same execution trigger (before update) so it would only let me save it if it was empty. Solution was to make all in one trigger.

avinash.munguravinash.mungur

Just try the following solution.

 

Righ click on the object > Force.com > Work Online.

 

Worked fine for me.

Frank Mamone 5Frank Mamone 5
This actually worked for me too!  Incredible, after chasing my tail for 2 days!
Taresh Pandey 19Taresh Pandey 19
I'm Facing this same issue, I have configured eclipse with salesforce production(EE). I shouldn't have done this but I didn't have any other option.
anyway; I'm able to change any apex class, trigger and VF which are already present in production, but I need to create new Classes and Triggers.
I can create new trigger and class locally but unable to upload it to server. Please refer following imageUser-added image
Please suggest me solution for this.


Regards'
Taresh Pandey
Dreamstel TechnologiesDreamstel Technologies


Step 1: Select the desired class that needs to be deployed on server. Right Click on the desired Class, go inside Force.com


User-added image






Step2: Click on ‘Save to Server’. Only for the first time it will ask to synchronise with server, select ‘No’. After that it will ask to save the selected component(‘s) to the server, select ‘Yes’.
The selected code will be deployed over the server.