• Sarbello
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

Odd issue: I have a Class (Class A) that requires code coverage. I write my code coverage from Class B. When I run Class B (decorated with '@isTest', and methods with ‘testMethod’) the test runs fine. I confirm that Class A was tested and even place System.Debug statements to demonstrate it went through the logic in Class A. The issue is Class A always shows 0% coverage. For reference, Class A makes my callout. However I’ve wrapped the WebServiceCallout.Invoke with a ‘if (!Test.isRunningTest())’

 

Any thoughts?


Thanks - Dave

This should be easy but...

 

I have 2 custom objects – "Product" and "Related Product".

 

"Product" has fields that include Price, Category, Description, etc..


"Related Product" only has a single field – master-detail back against "Product".
Also it has an Auto Number field for the Name – I did this so that the user would only have to select a related product and not have to type some other data in.

 

On the tab "Product" I get a related list of "Related Products" but the listview only shows
the auto number (ie: RP-0001). I want to add more fields to the listview on the "Product" tab but when I go to the Page Layout on the "Product" object and click the wrench on the related list I have no other field that would be meaningful to include.

 

OK – so I go back to "Related Product" object and add a Formula field and indeed this formula field shows up on the "Product" tab – page layout – "Related Product" related list - wrench area.

 

The issue is creating the formula field – nothing I select (fields to include) allows me to get the name of the product the user selected (on the "Related Product". Its always a cryptic ID or the Product name of the parent or something else.

 

Any ideas?

 

Thanks - Dave

I have some code generating OAuth signature and sending request to NetSuite.
I reviewed all the parameters I send to NetSuite with their developers and they told me that I have some issue with oauth_signature.

I will really appreciate if you take a look and tell me what I am doing wrong.
 
public String timestamp {get; set;} //seconds since unix epoch
    public String nonce {get; set;} //random number for making request unique
    public Map<String, String> oauth_params {get; set;} //store oauth params for signature generation   
    public OAuthService__c ns_oauth	{get; set;} //oauth data for ns -> salesforce
    	
    public String GenerateSignature(String httpMethod) {
    	
    	ns_oauth = [select Consumer_Key__c, Consumer_Secret__c, Authorization_URL__c, Realm__c, 
    						   (select token__c, secret__c from Tokens__r)
    					  from OAuthService__c
    					 where Name = 'SalesForce' limit 1];
    		
    	timestamp = String.valueOf(DateTime.now().getTime()/1000); //seconds since unix epoch
    	nonce = String.valueOf(Crypto.getRandomLong()); //random number
    
    	oauth_params = new Map<String, String>();
    
    	if(ns_oauth != null) { //store parameters for signature creating
    		oauth_params.put('oauth_version', '1.0');
    		oauth_params.put('oauth_nonce', nonce);
    		oauth_params.put('oauth_timestamp', timestamp);
    		oauth_params.put('oauth_consumer_key', ns_oauth.Consumer_Key__c);
    		oauth_params.put('oauth_token', ns_oauth.Tokens__r[0].token__c);
    	}
    		
    	String sig = normalizeUrl(ns_oauth.Authorization_URL__c);  //signature starts with normalized url (with port number)
    	Blob sigMac; //hash of signature
    	
    	sig = httpMethod.toUpperCase() + '&' + EncodingUtil.urlEncode(sig, 'UTF-8');
    		
    	//sort parameters  before appending to signature 
    	List<string> sortParams = new List<string>(oauth_params.keySet());
    	sortParams.sort();
    	
    	//append all the params for signature
    	for(String param_key : oauth_params.keySet()) {
    		sig += '&' + param_key + '=' + oauth_params.get(param_key);
    	}
    
    	//compute HASH using SHA-1 algorithm
    	//where key is acombination of concumer secret and token secret
    	
    	String hash_key = ns_oauth.Consumer_Secret__c + '&' + ns_oauth.Tokens__r[0].secret__c;
    
    	sigMac = Crypto.generateMac('HmacSHA1', Blob.valueOf(sig), Blob.valueOf(hash_key));
    
    	return EncodingUtil.urlEncode(EncodingUtil.base64Encode(sigMac), 'UTF-8');
    
    }
I get in response following:
 
{"error" : {"code" : "INVALID_LOGIN_ATTEMPT", "message" : "Invalid login attempt."}}