• David Holland 6
  • NEWBIE
  • 115 Points
  • Member since 2015

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 7
    Questions
  • 38
    Replies
Hi All,
I did a Class/methods who seems to be working into Sand box.
I have started writting a test class, but i always have a fatal error :
FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject
what cannot be true...

I explain myself.
My Trigger is supposed to fire after insert/update on Quotelineitem
So I have a created an Opportunity / Quote / quotelineItem on SAND box.

I have runned some SQL to extract the ID of the QuotelineItem.

into my test class i did a basic stuff as :

        // 3_Insert QLI SRV- professional Service (check costs calculation)
        QuoteLineItem testqli= new QuoteLineItem(Id='0QL250000000VXFGXX', Quantity=2);
        update testqli;


which fire the next :
 for (QuotelineItem qli :quoteLines)   {
            QuoteLineItem newqli = new QuoteLineItem();
                        //initializing the new List           
               newqli.Id=qli.Id;      
                       //Extract the Product informations
            String ProdId = qli.Product2Id;                              //system.debug shows that qli.product2Id is : "01t25000000V73gAXX"
Product2 prod = [SELECT Id, ProductCode, Provider__c, Purchase_Purchase_isP__c, Is_Maintenance__c, PurchaseP__c, Purchase_Price__c, Extra__c, CurrencyIsoCode FROM Product2 WHERE Id = :ProdId LIMIT 1];

which cause the Fatal Error as no row returned.

however in DEV console /SQL :

SELECT product2Id from quotelineItem where id ='0QL250000000VXFGXX'
result is : '01t25000000V73gAXX'                       //what is the expected result

SELECT Id, ProductCode, Provider__c, Purchase_Purchase_isP__c, Is_Maintenance__c, PurchaseP__c, Purchase_Price__c, Extra__c, CurrencyIsoCode FROM Product2 WHERE Id = 01t25000000V73gAXX LIMIT 1
result is the expected one (productCode : SRV-CTRK-D, Provider__s : Test, CurrencyIsoCode : GBP...etc)

Why developper console returns a Row, but TestClass doesn't ...for same SQL...no sense ???

could you help please ?
Many thanks

 
Hi All,
     I had gone through some problems working withDescription field so now I got a solution to work with "Long Text Area DataType", if you want to count() the records or other filtering things with Description.
   I made a custom field "Notes__c"(Text Area) in contact object and using Trigger i copied the contents of Description field to Notes__c.
here is the code:
trigger CopydescToNotes on Contact (before insert,before update) {
for(Contact c : Trigger.new)
if(c.Description!=null)
c.Notes__c=c.Description;
}


Thanks 
Shephali
We have a custom written chat console in Salesforce on a visualforce page.

Sometimes, when rerendering the page and calling controller actions through Javascript, the page refreshes completely and just displays the actual Javascript methods:

User-added image

Any help would be greatly appreciated!

<apex:actionFunction name="refreshData" action="{!refreshData}" oncomplete="refreshDataFinished(); reRenderQueue();" reRender="sideMenu, reRenderQueue, alertSection, autoResponseCounterBadge"/>


Let me know if you need anything extra!
We have a custom written chat console in Salesforce on a visualforce page.

Sometimes, when rerendering the page and calling controller actions through Javascript, the page refreshes completely and just displays the actual Javascript methods:

User-added image

Any help would be greatly appreciated!
 
<apex:actionFunction name="refreshData" action="{!refreshData}" oncomplete="refreshDataFinished(); reRenderQueue();" reRender="sideMenu, reRenderQueue, alertSection, autoResponseCounterBadge"/>



Let me know if you need anything extra!
Hey

I am trying to deploy from our Sandbox to production and am finding some weird issues!

Tests that are passing in both testing and production (both through the Dev Console and Mavens Mate) are failing when I am deploying classes that have no relation to the ones failing!

This is one of the errors that I am getting, despite the fact I don't reference this field ANYWHERE in ANY classes:

System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Task: bad field names on insert/update call: ActivityOriginType: [ActivityOriginType] 


Just wondered if anyone else has been encountering the same issues since the upgrade.

There are a couple of other tests that have failed, but this is due to error messages changing etc, but the above error I do not understand!
Hi there

I have created a Salesforce site, activated it and added the necessary class to the site user permission, but whenever I am trying to call the public apex rest service, I am getting that the site is "under construction".

We have the exact same set up in another org, which is working, so I am confused what I might have missed.

Any help would be greatly appreciated!
Hi all

We have 4 batch jobs within our org and 3 of them seem to have issues in our production environment.

They are scheduled to run at different times of the day (late at night/early morning to reduce overhead), but all have issues.

1 of them doesn't even show up in the "Scheduled job" list, one says "Aborted by user" (cannot be done as this is an automated user that no obe logs in to, and the third gives a Java compile error).

These jobs all run successfully in full sandbox and if I run them anonymously through Apex.

Please let me know any ideas!
Hi all, hoping someone can help.

I won't bore you with the ins and out of the code, but basically, I have a query string I am dynamically populating from an SObject and seeing if it is true.

The code snippet is below:
 
private static Boolean shouldShowInInbox(String queryString, SObject sObjectToCheck, Set<String> fieldsToCheck){
        for(String fieldToCheck : fieldsToCheck){
            String fieldValueOnObject = String.valueOf(sObjectToCheck.get(fieldToCheck));
            queryString = queryString.replaceAll(fieldToCheck, String.isBlank(String.valueOf(fieldValueOnObject)) ? '' : String.valueOf(fieldValueOnObject));
        }
        System.debug(queryString);
        System.debug(Boolean.valueOf(queryString));
        return Boolean.valueOf(Boolean.valueOf(queryString));
    }



It is returning me these two debugs and I have no idea why!

qforcesupport@quintessentially.com == qforcesupport@quintessentially.com
false





So it is stating that the two values are not the same....

Please someone help!
 
We have a VF page for creating a new custom object, over writing the standard create/edit page.

When a user tries to save a record, we want to leverage the Duplicate Management checker, which I have managed to do, by doing Database.SaveResult and looping through the errors to see if it is an instance of "Database.DuplicateError". 

This displays all the errors on the VF page, however I wish the user to then be able to ignore the duplicates and allow them to save. I thought that by at that point adding "allowSave" as a header equal to true, this would allow the insert, however it doesn't even run the save method a second time.

Code is below but shortened for ease of viewing.
 
public PageReference save(){
		Database.DMLOptions dml = new Database.DMLOptions(); 
		dml.DuplicateRuleHeader.AllowSave = hasDuplicateResult;
		Database.SaveResult saveResult = Database.insert(supplierToUse, dml);
        if (!saveResult.isSuccess()) {        	
            for (Database.Error error : saveResult.getErrors()){
            	ApexPages.addMessage(
	            	new ApexPages.Message(
	                    ApexPages.Severity.ERROR, 
	                    error.getMessage()
	                )
	            );
                if (error instanceof Database.DuplicateError) {
                    duplicateRecords = (List<Supplier__c>) DuplicateFinder.duplicatesFound(error);
                    hasDuplicateResult = !duplicateRecords.isEmpty();
                    ApexPages.addMessage(
		            	new ApexPages.Message(
		                    ApexPages.Severity.WARNING, 
		                    'Please press save again if you wish to save this supplier anyway.'
		                )
		            );
                }
            }
            return null;
        }
    return new PageReference('/' + supplierToUse.Id);
}

Please can someone let me know what I need to do to correct this!
 
Hi All,
I did a Class/methods who seems to be working into Sand box.
I have started writting a test class, but i always have a fatal error :
FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject
what cannot be true...

I explain myself.
My Trigger is supposed to fire after insert/update on Quotelineitem
So I have a created an Opportunity / Quote / quotelineItem on SAND box.

I have runned some SQL to extract the ID of the QuotelineItem.

into my test class i did a basic stuff as :

        // 3_Insert QLI SRV- professional Service (check costs calculation)
        QuoteLineItem testqli= new QuoteLineItem(Id='0QL250000000VXFGXX', Quantity=2);
        update testqli;


which fire the next :
 for (QuotelineItem qli :quoteLines)   {
            QuoteLineItem newqli = new QuoteLineItem();
                        //initializing the new List           
               newqli.Id=qli.Id;      
                       //Extract the Product informations
            String ProdId = qli.Product2Id;                              //system.debug shows that qli.product2Id is : "01t25000000V73gAXX"
Product2 prod = [SELECT Id, ProductCode, Provider__c, Purchase_Purchase_isP__c, Is_Maintenance__c, PurchaseP__c, Purchase_Price__c, Extra__c, CurrencyIsoCode FROM Product2 WHERE Id = :ProdId LIMIT 1];

which cause the Fatal Error as no row returned.

however in DEV console /SQL :

SELECT product2Id from quotelineItem where id ='0QL250000000VXFGXX'
result is : '01t25000000V73gAXX'                       //what is the expected result

SELECT Id, ProductCode, Provider__c, Purchase_Purchase_isP__c, Is_Maintenance__c, PurchaseP__c, Purchase_Price__c, Extra__c, CurrencyIsoCode FROM Product2 WHERE Id = 01t25000000V73gAXX LIMIT 1
result is the expected one (productCode : SRV-CTRK-D, Provider__s : Test, CurrencyIsoCode : GBP...etc)

Why developper console returns a Row, but TestClass doesn't ...for same SQL...no sense ???

could you help please ?
Many thanks

 
I am not able to access standard & custom fields of Opportunity Object in my apex classes. It gives me error "Variable does not exist" even for standard fields of Opportunity.

My requirement is 
In my VF PAGE ,whenever i was entered some value with the SEARCH functionality at the same time whenever i  was click on SUBMIT button that related records was displaying.whenever i was click on CLEAR button that related records will clear but it is not cleared.

THANKS

RANGA
 

Hi
Can any one help me out of this error

System.QueryException: List has no rows for assignment to SObject .

error line recordtype = [SELECT Id FROM RecordType WHERE SobjectType = 'EXM__c' AND DeveloperName = : developerName LIMIT 1].Id;

Thanks.
Hi,
@isTest
 private class sendReminderwgntoemployees_Test{
  Static testmethod void sendReminderwgntoemployees_TestMethod(){
  
  Date td = system.Today();
   User u;
   User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
    System.runAs (thisUser) {

            Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
            

            UserRole r = [SELECT Id FROM UserRole WHERE Name=' Admin'];

            u = new User(alias = 'sindu1', email='sandvarma1@gmail.com',

                emailencodingkey='UTF-8', lastname='Smith',

                languagelocalekey='en_US',

                localesidkey='en_US', profileid = p.Id, userroleid = r.Id,

                timezonesidkey='America/Chicago',
                username='sandvarma1@gmail.com');

            insert u;
    }  
 recordtype rt=[select id from recordtype where DeveloperName = 'Employee'];
        Contact con=WCT_UtilTestDataCreation.createEmployee(rt.id);
       // con.CreatedDate = td;
        insert con;
        list<_Wage_Notice__c> lstwgn = new list<_Wage_Notice__c>();
        _Wage_Notice__cwgn = new _Wage_Notice__c();
        wgn._Related_To__c = con.id;
        wgn.WTPAA_Status__c = 'sent';
    
      
       lstwgn.add(wgn);
        insert lstwgn;
        system.debug('created by user' +lstwgn[0].createdby);
        system.debug('size********' +lstwgn.size());
        system.debug('value of the status' +lstwgn[0].WTPAA_Status__c);
        system.assertEquals('sent', lstwgn[0].WTPAA_Status__c );
  • October 13, 2015
  • Like
  • 0
i want to create a task when the status of picklist is changed by the user .
I want to cover atleast 75% of class. Now am on 74% just need only one percent but i found it hard. One part of my method is not covering that contains variables and its assignments.
if( Discount != 0 && MDiscount != 0)
                {
           
                    Discount = ((UnitRate )*Discount)/100; 
                    MDiscount = ((UnitRate  - Discount)*MDiscount)/100;
                    objvar.Discount__c = Discount;
                    objvar.MDiscount__c = MDiscount;
                }
                else if(Discount != 0 && MDiscount == 0)
                {
                   
                    Discount = ((UnitRate )*Discount)/100; 
                    objvar.Discount__c = Discount;
                }
                else if(Discount == 0 && MDiscount != 0)
                {
                
                    MDiscount = ((UnitRate )*MDiscount)/100;
                    objvar.MDiscount__c= MDiscount;
    
                }
                else
                {
                    objvar.Discount__c = 0;
                    objvar.MDiscount__c = 0;
                }

above apex class code is one part of condition checking. This part is not covering in my Test class. Help me to cover this.
variables are Discount, MDiscount and UnitRate
Hi All,
     I had gone through some problems working withDescription field so now I got a solution to work with "Long Text Area DataType", if you want to count() the records or other filtering things with Description.
   I made a custom field "Notes__c"(Text Area) in contact object and using Trigger i copied the contents of Description field to Notes__c.
here is the code:
trigger CopydescToNotes on Contact (before insert,before update) {
for(Contact c : Trigger.new)
if(c.Description!=null)
c.Notes__c=c.Description;
}


Thanks 
Shephali
Hello ~ I'm an admin that just started at a new company and cleaning up code of a developer that has left. There were a bunch of hard-coded Ids in code and configurations and I've attempted to replace them, in part, with a Custom Hierarchy Setting. I updated some code to reference the Id__c field on the custom setting instead of hard-coding the id, but I'm getting the "INVALID_CROSS_REFERENCE_KEY, Owner ID: owner cannot be blank: [OwnerId]" error. The code was hard-coding a Queue Id (named "Trash") and setting the owner of a Case record. My custom setting is named Trash_Queue__c. I've ensured that the Custom Setting is populated with the correct 18 character Id for the Queue. When I use execute anonymous to test if I am setting the trashQueue variable correctly, I get the result I want. What am I missing? Here is a snippet of the code:
 
@isTest
private class TestSchedulableClass {
    
    static testmethod void test() {
        test.startTest();
        
        Trash_Queue__c trashQueueSetting = Trash_Queue__c.getOrgDefaults();
            
        String trashQueue = trashQueueSetting.Id__c;
        
        Case delOldCase= new Case();
        delOldCase.OwnerId =trashQueue;
        insert delOldCase;

        Test.stopTest();   
     }
}

Thanks!
Meredith
Replace each query by schema describe call:
Replcae this:
//REPLACE THIS LINE
RecordType closedWonRecordType = [SELECT Id from RecordType WHERE SobjectType = 'Opportunity' AND Name = 'Closed Won
' LIMIT 1];

//FROM
Id closedWonRecordTypeId = Opportunity.getDescribe().getRecordTypeInfosByName().get('Closed Won').getRecordTypeId();
I am a small business owner and use Salesforce Enterprise.  I am not a salesforece developer. I need a small and likely simple project done and am looking to pay someone to devellop it.   Very simply I need to send emails to leads and clients who are turning 65.  I'd like to send one email every month beginning six months before they're 65th birthday.  If anyone is interested in this project, please email:  ted@usa-healthinsurance.com.

Thank you
Hi there

I have created a Salesforce site, activated it and added the necessary class to the site user permission, but whenever I am trying to call the public apex rest service, I am getting that the site is "under construction".

We have the exact same set up in another org, which is working, so I am confused what I might have missed.

Any help would be greatly appreciated!
I am almost done with my test class and I ended up with 2 lines in my class that are not covered by my test class.

        if(Integer.valueOf(System.Today().month()) - 1 == 0) {
            mMonth = '12';
             mYear = String.valueOf(Integer.valueOf(System.Today().year()) - 1);

         } else {
            mMonth= String.valueOf(Integer.valueOf(System.Today().month()) - 1);
             mYear = String.valueOf(Integer.valueOf(System.Today().year()));
         } 
How do I cover the 2 lines of code ( bold ones )?
Some of my other classes also uses that same lines of code. Thanks!!
Hi all

We have 4 batch jobs within our org and 3 of them seem to have issues in our production environment.

They are scheduled to run at different times of the day (late at night/early morning to reduce overhead), but all have issues.

1 of them doesn't even show up in the "Scheduled job" list, one says "Aborted by user" (cannot be done as this is an automated user that no obe logs in to, and the third gives a Java compile error).

These jobs all run successfully in full sandbox and if I run them anonymously through Apex.

Please let me know any ideas!
I am a small business owner and use Salesforce Enterprise.  I am not a salesforece developer. I need a small and likely simple project done and am looking to pay someone to devellop it.   Very simply I need to send emails to leads and clients who are turning 65.  I'd like to send one email every month beginning six months before they're 65th birthday.  If anyone is interested in this project, please email:  ted@usa-healthinsurance.com.

Thank you

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.