• David Joshua
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 16
    Replies
Hi, 

I would like to use System.assertEquals(ANY expected, ANY actual, ANY msg) with something like that : 
    @IsTest
    static void testRecoverValue() {

        Integer val1 = 1353;
        Integer val2 = 1300;
        Integer val3 = 0; 

        String json = FranceOperation_Utility_ReloadImpressions.getjsonFranceOperationTargetingDistibution();
        Integer val = FranceOperations_TargetDistri.parse(json);
        System.assertEquals(val1||val2||val3, val, 'test for function recoverValue() suceeded');
    }
I know the syntax on my last line is not correct but I would like to know the proper way to write it. Is there a way to include many integers in my value expected. How do I do that ? Should it be more like this : 
System.assertEquals(val1, val, 'test for function recoverValue() suceeded') || 
System.assertEquals(val2, val, 'test for function recoverValue() suceeded') || 
System.assertEquals(val3, val, 'test for function recoverValue() suceeded');
(I'm a begginer, and moreover, who has not written many tests before. Thank you for your patience !)
 
Hi, 

Why can I do 
        Integer val_media_deliveries = 66;
        Integer val_impressions = 55;
        Integer val_clips = 44;
        
        List<Integer> valuesToReturn = new List<Integer>(1);
        
        valuesToReturn.add(0,val_media_deliveries);
        valuesToReturn.add(1,val_impressions);
        valuesToReturn.add(2,val_clips);

        return valuesToReturn;
But not : 
        Integer val_media_deliveries = 66;
        Integer val_impressions = 55;
        Integer val_clips = 44;
        
        List<Integer> valuesToReturn = new List<Integer>(0);
        
        valuesToReturn.add(0,val_media_deliveries);
        valuesToReturn.add(1,val_impressions);
        valuesToReturn.add(2,val_clips);

        return valuesToReturn;
(because I get this error : )
{faultcode:'soapenv:Client', faultstring:'System.ListException: List 
index out of bounds: 0

Class.FranceOperations_TargetDistri.parse: line 32, column 1
Class.FranceOperations_TargetDistri.load: line 80, column 1
Class.FranceOperations_ReloadImpressions.getTotalImpressions: line 60, column 1',}
I would my result to be : 
my values : 66,55,44

but not :
my values : 66,55,44,

What is it I am missing ? ​​​​​​​



 
Hello, 

I have a range problem with one of my variables : 
String MCLU1 = 'BK2200 0015 -- 41';

        if (MCLU1 != null || MCLU1 != '') {
            String bk = null; 
            String bk_full = null;
            String bk_extension = '--'; 
            String [] bkAfterSplit = null;
    
            bk_full = MCLU1; 
            if (bk_full.contains(bk_extension)) {
                bkAfterSplit = bk_full.split(' -- ');
                bk = bkAfterSplit[0];
                System.debug(LoggingLevel.DEBUG, 'bk inside my if : ' + bk);
            } else {
                bk = bk_full;
                System.debug(LoggingLevel.DEBUG, 'bk inside my else : ' + bk);
            }
            
        } else {
            System.debug(LoggingLevel.DEBUG, 'MCLU1__c is empty');
        }
        String external_id = 'FRA-BLIP-' + bk;
        System.debug(LoggingLevel.DEBUG, 'bk outside my if/else : ' + bk);
        System.debug(LoggingLevel.DEBUG, 'external_id : ' + external_id);
line 22, I need to get my bk variable but i get a Variable does not exist: bk. And I don't seem to understand why. I try almost the same code in eclipse and it worked : 
public class BkDoesNotExist {

	public static void main(String[] args) {
		
		String MCLU1__c = "BK2200 0015 -- 41";
		
		String bk = null; 
		String bk_full = null;
		String bk_extension = "--"; 
		String [] bkAfterSplit = null;
		
        if (MCLU1__c != null || MCLU1__c != "") {
            
        // variables nécessaires pour split mon BK proprement 

            bk_full = MCLU1__c; 
            if (bk_full.contains(bk_extension)) {
                bkAfterSplit = bk_full.split(" -- ");
                bk = bkAfterSplit[0];
                System.out.println("bk inside my if : " + bk);
            } else {
                bk = bk_full;
            }
            
        } else {
            System.out.println("MCLU1__c is empty");
        }

        String external_id = "FRA-BLIP-"+bk; 
        System.out.println("bk outside my if : " + bk);
        System.out.println("external_id : " + external_id);
	}

}
result in console : 
bk inside my if : BK2200 0015
bk outside my if : BK2200 0015
external_id : FRA-BLIP-BK2200 0015
Any idea on what I am missing here ? 

 

 
I got this "Variable Does Not Exist" problem. I have a class "FranceOperations_ReloadImpressions" : 
 
global class FranceOperations_ReloadImpressions {

    webservice static String getTotalImpressions(String id) 
    {

        France_Operations__c [] myOperation = [select id, Mecanic_operation_LU__r.id, Mecanic_operation_LU__r.Name, Vault_Adgroup__c, VaultClone_Operation_Id__c, 
            MCLU__c, MCLU1__c, MCLU2__c, MCLU3__c, MCLU4__c, MCLU5__c, MCLU6__c, MCLU7__c, MCLU8__c, MCLU9__c, MCLU10__c, 
            MCLU11__c, MCLU12__c, MCLU13__c, MCLU14__c, MCLU15__c, MCLU16__c, MCLU17__c, MCLU18__c, MCLU19__c, MCLU20__c, 
            Status__c, ID_Request_Number__c, Eligibilit_VAULT__c, Operation_ID__c from France_Operations__c where Id = :id ];
        System.debug(LoggingLevel.DEBUG, 'myOperation : ' + myOperation);
        System.debug(LoggingLevel.DEBUG, 'MCLU1__c : ' + MCLU1__c);

        if (myOperation.MCLU1__c != null || myOperation.MCLU1__c != '') {
        
            String bk = null; 
            String bk_full = null;
            String bk_extension = '--'; 
            String [] bkAfterSplit = null;

            bk_full = myOperation.MCLU1__c; 
            if (bk_full.contains(bk_extension)) {
                bkAfterSplit = bk_full.split(' -- ');
                bk = bkAfterSplit[0];
            } else {
                bk = bk_full;
            }
            
        } else {
            System.debug(LoggingLevel.DEBUG, 'MCLU1__c is empty');
        }

        // more code

}

Basically, I recover data from fields from my current page. But I get the error "Variable does not exist: MCLU1__c" since 

System.debug(LoggingLevel.DEBUG, 'MCLU1__c : ' + MCLU1__c);
But I do get myOperation with 
System.debug(LoggingLevel.DEBUG, 'myOperation : ' + myOperation);

My class is global and my webservice is static so I don't understand the range problem. I also did the same in another class and I did not get this problem... 

Any input would be greatly appreciated !

I do not understand why everytime I try to post on a subject on this forum, I always get a 503 error. And sometimes, the post is really posted and sometimes, it is not. Am I the only one getting this error ?
Hello, 

I've made a custom button with some JavaScript behind which calls an  API. 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}

//alert('alert test');

var returnStatus = sforce.apex.execute("FranceOperations_RemoveStore", "resetSelectedFields", {id:"{!France_Operations__c.Id}"});

var returnSplited = returnStatus.toString().split("--");
if(returnSplited[0] != '0')
{
   alert(returnSplited[1]);
}

console.log("object published after modification "+"{!France_Operations__c.Id}");

location.reload();
And when I use it, here is the error that I get : 
a problem with the OnClick JavaScript for this button or link was 
encountered : 

{faultcode:'soapenv:Client', faultstring:'No service available for class 
'FranceOperation_RemoveStore'',}
The thing is the error state 'FranceOperation_RemoveStore' but the code behind my button calls a class named "FranceOperations_RemoveStore". There is a -s after 'operation'. I am 100% sure of that since I have checked it twice. Is there some kind of basic error I am missing ? It looks like I did not connect my button properly to my class and its method. Or maybe I am missing something else ?

If anybody has a better understanding of this then me, any advice or input would be greatly appreciated ! 
Thanks in advance !

 
Hi, 

I would like to use System.assertEquals(ANY expected, ANY actual, ANY msg) with something like that : 
    @IsTest
    static void testRecoverValue() {

        Integer val1 = 1353;
        Integer val2 = 1300;
        Integer val3 = 0; 

        String json = FranceOperation_Utility_ReloadImpressions.getjsonFranceOperationTargetingDistibution();
        Integer val = FranceOperations_TargetDistri.parse(json);
        System.assertEquals(val1||val2||val3, val, 'test for function recoverValue() suceeded');
    }
I know the syntax on my last line is not correct but I would like to know the proper way to write it. Is there a way to include many integers in my value expected. How do I do that ? Should it be more like this : 
System.assertEquals(val1, val, 'test for function recoverValue() suceeded') || 
System.assertEquals(val2, val, 'test for function recoverValue() suceeded') || 
System.assertEquals(val3, val, 'test for function recoverValue() suceeded');
(I'm a begginer, and moreover, who has not written many tests before. Thank you for your patience !)
 
Hi, 

Why can I do 
        Integer val_media_deliveries = 66;
        Integer val_impressions = 55;
        Integer val_clips = 44;
        
        List<Integer> valuesToReturn = new List<Integer>(1);
        
        valuesToReturn.add(0,val_media_deliveries);
        valuesToReturn.add(1,val_impressions);
        valuesToReturn.add(2,val_clips);

        return valuesToReturn;
But not : 
        Integer val_media_deliveries = 66;
        Integer val_impressions = 55;
        Integer val_clips = 44;
        
        List<Integer> valuesToReturn = new List<Integer>(0);
        
        valuesToReturn.add(0,val_media_deliveries);
        valuesToReturn.add(1,val_impressions);
        valuesToReturn.add(2,val_clips);

        return valuesToReturn;
(because I get this error : )
{faultcode:'soapenv:Client', faultstring:'System.ListException: List 
index out of bounds: 0

Class.FranceOperations_TargetDistri.parse: line 32, column 1
Class.FranceOperations_TargetDistri.load: line 80, column 1
Class.FranceOperations_ReloadImpressions.getTotalImpressions: line 60, column 1',}
I would my result to be : 
my values : 66,55,44

but not :
my values : 66,55,44,

What is it I am missing ? ​​​​​​​



 
Hello, 

I have a range problem with one of my variables : 
String MCLU1 = 'BK2200 0015 -- 41';

        if (MCLU1 != null || MCLU1 != '') {
            String bk = null; 
            String bk_full = null;
            String bk_extension = '--'; 
            String [] bkAfterSplit = null;
    
            bk_full = MCLU1; 
            if (bk_full.contains(bk_extension)) {
                bkAfterSplit = bk_full.split(' -- ');
                bk = bkAfterSplit[0];
                System.debug(LoggingLevel.DEBUG, 'bk inside my if : ' + bk);
            } else {
                bk = bk_full;
                System.debug(LoggingLevel.DEBUG, 'bk inside my else : ' + bk);
            }
            
        } else {
            System.debug(LoggingLevel.DEBUG, 'MCLU1__c is empty');
        }
        String external_id = 'FRA-BLIP-' + bk;
        System.debug(LoggingLevel.DEBUG, 'bk outside my if/else : ' + bk);
        System.debug(LoggingLevel.DEBUG, 'external_id : ' + external_id);
line 22, I need to get my bk variable but i get a Variable does not exist: bk. And I don't seem to understand why. I try almost the same code in eclipse and it worked : 
public class BkDoesNotExist {

	public static void main(String[] args) {
		
		String MCLU1__c = "BK2200 0015 -- 41";
		
		String bk = null; 
		String bk_full = null;
		String bk_extension = "--"; 
		String [] bkAfterSplit = null;
		
        if (MCLU1__c != null || MCLU1__c != "") {
            
        // variables nécessaires pour split mon BK proprement 

            bk_full = MCLU1__c; 
            if (bk_full.contains(bk_extension)) {
                bkAfterSplit = bk_full.split(" -- ");
                bk = bkAfterSplit[0];
                System.out.println("bk inside my if : " + bk);
            } else {
                bk = bk_full;
            }
            
        } else {
            System.out.println("MCLU1__c is empty");
        }

        String external_id = "FRA-BLIP-"+bk; 
        System.out.println("bk outside my if : " + bk);
        System.out.println("external_id : " + external_id);
	}

}
result in console : 
bk inside my if : BK2200 0015
bk outside my if : BK2200 0015
external_id : FRA-BLIP-BK2200 0015
Any idea on what I am missing here ? 

 

 
I got this "Variable Does Not Exist" problem. I have a class "FranceOperations_ReloadImpressions" : 
 
global class FranceOperations_ReloadImpressions {

    webservice static String getTotalImpressions(String id) 
    {

        France_Operations__c [] myOperation = [select id, Mecanic_operation_LU__r.id, Mecanic_operation_LU__r.Name, Vault_Adgroup__c, VaultClone_Operation_Id__c, 
            MCLU__c, MCLU1__c, MCLU2__c, MCLU3__c, MCLU4__c, MCLU5__c, MCLU6__c, MCLU7__c, MCLU8__c, MCLU9__c, MCLU10__c, 
            MCLU11__c, MCLU12__c, MCLU13__c, MCLU14__c, MCLU15__c, MCLU16__c, MCLU17__c, MCLU18__c, MCLU19__c, MCLU20__c, 
            Status__c, ID_Request_Number__c, Eligibilit_VAULT__c, Operation_ID__c from France_Operations__c where Id = :id ];
        System.debug(LoggingLevel.DEBUG, 'myOperation : ' + myOperation);
        System.debug(LoggingLevel.DEBUG, 'MCLU1__c : ' + MCLU1__c);

        if (myOperation.MCLU1__c != null || myOperation.MCLU1__c != '') {
        
            String bk = null; 
            String bk_full = null;
            String bk_extension = '--'; 
            String [] bkAfterSplit = null;

            bk_full = myOperation.MCLU1__c; 
            if (bk_full.contains(bk_extension)) {
                bkAfterSplit = bk_full.split(' -- ');
                bk = bkAfterSplit[0];
            } else {
                bk = bk_full;
            }
            
        } else {
            System.debug(LoggingLevel.DEBUG, 'MCLU1__c is empty');
        }

        // more code

}

Basically, I recover data from fields from my current page. But I get the error "Variable does not exist: MCLU1__c" since 

System.debug(LoggingLevel.DEBUG, 'MCLU1__c : ' + MCLU1__c);
But I do get myOperation with 
System.debug(LoggingLevel.DEBUG, 'myOperation : ' + myOperation);

My class is global and my webservice is static so I don't understand the range problem. I also did the same in another class and I did not get this problem... 

Any input would be greatly appreciated !

I do not understand why everytime I try to post on a subject on this forum, I always get a 503 error. And sometimes, the post is really posted and sometimes, it is not. Am I the only one getting this error ?
Hello, 

I've made a custom button with some JavaScript behind which calls an  API. 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}

//alert('alert test');

var returnStatus = sforce.apex.execute("FranceOperations_RemoveStore", "resetSelectedFields", {id:"{!France_Operations__c.Id}"});

var returnSplited = returnStatus.toString().split("--");
if(returnSplited[0] != '0')
{
   alert(returnSplited[1]);
}

console.log("object published after modification "+"{!France_Operations__c.Id}");

location.reload();
And when I use it, here is the error that I get : 
a problem with the OnClick JavaScript for this button or link was 
encountered : 

{faultcode:'soapenv:Client', faultstring:'No service available for class 
'FranceOperation_RemoveStore'',}
The thing is the error state 'FranceOperation_RemoveStore' but the code behind my button calls a class named "FranceOperations_RemoveStore". There is a -s after 'operation'. I am 100% sure of that since I have checked it twice. Is there some kind of basic error I am missing ? It looks like I did not connect my button properly to my class and its method. Or maybe I am missing something else ?

If anybody has a better understanding of this then me, any advice or input would be greatly appreciated ! 
Thanks in advance !