• Michele Toscano
  • NEWBIE
  • 100 Points
  • Member since 2014
  • Applications Manager
  • Cabot Corporation

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 21
    Replies
folowing is the lighting code : 

<aura:component controller="ActivateAgreementController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"  >
    <aura:handler name="init" value="{!this}" action="{!c.validateandactivateagreement}"/>
    <aura:attribute name="smsg" type="Boolean" default="false"/>
    <aura:attribute name="emsg" type="Boolean" default="false"/>
    <aura:attribute name="message" type="String"/>
    <aura:if isTrue="{!v.emsg}">
        <ui:message title="Error" severity="error" closable="false">
           Owner Update failed. Please try again later or contact your System Admin.
        </ui:message>
    </aura:if>
    <aura:if isTrue="{!v.smsg}">
        <ui:message title="Confirmation" severity="confirm" closable="false">
            <div>

          ResultMessage:<ui:outputText value="{!v.message}"/>

     </div>
           Successfully updated Owner.
        </ui:message>
    </aura:if>
</aura:component>

({
    validateandactivateagreement : function(component, event, helper) {
       alert('start1');
        var action = component.get("c.agreementactivate");
        action.setParams({"id": component.get("v.recordId")});
        action.setCallback(component,
        function(response) {
            var state = response.getReturnValue();
            if (state === true){
                $A.get('e.force:refreshView').fire();
                component.set("v.smsg", true);
                 cmp.set("v.message", "hi");
            } else {
                 component.set("v.emsg", true);
            }
        }
        );
        $A.enqueueAction(action);
        
    }
})

global with sharing class ActivateAgreementController {
    //Constructor
    public ActivateAgreementController(ApexPages.StandardController controller) {
    }
    //Accepts the record id and sends a boolean status about the updation
    @AuraEnabled @RemoteAction
    global static Boolean agreementactivate(Id Agreementid){
        try{
            //Group oppQueue = [select Id from Group where  Type = 'Queue' AND DeveloperName = 'Opportunity_Review_Queue'];
            //Opportunity crec = [Select Id, OwnerId from Opportunity where Id=:oppid];
            //crec.OwnerId = oppQueue.Id;
            //update crec;
            
            contract contract_record = [select Record_Type_Name__c,AccountId,telia_TC_Party__c,telia_Customer_contact_person__c,telia_Sales_person__c 
                                        ,telia_Sales_responsible__c ,telia_Confidentiality_class__c,telia_Start_date__c ,telia_Signature_alternative__c
                                        ,CustomerSignedId ,CustomerSignedDate,telia_Customer_Signature_Place__c,Telia_Signed_By__c,Telia_Signed_Date__c,Signatories_Required__c from 
                                        contract where Id=:Agreementid];
                                        
                                        
           return true;
        }
        catch(Exception e){
            return false;
        }
    }
}

its failling from quick action in lighting .error message : 
Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details.
Action failed: forceChatter:lightningComponent$controller$doInit [Error while creating content for lightning component quick action]
quickActionHandlerHelper.js failed to create component - forceChatter:lightningComponent
I'm at 50% code coverage of my test class.  How can I increase the coverage? 
Here is my apex class: (The lines bolded below are not covered...how can I cover them?)

Global class IncidentManagerCallout{ 
    public static IncidentManager.ArrayOfSHSHresult GetIMData(string email){ 
        IncidentManager.IncidentManagerWrapperSoap soapService = new 
            IncidentManager.IncidentManagerWrapperSoap (); 
        return soapService.IMSearch(email);
    } 
    public static IncidentManager.ArrayOfSHSHresult GetIMTimeStampSearchData(string email){     
        IncidentManager.IncidentManagerWrapperSoap soapService = new 

            IncidentManager.IncidentManagerWrapperSoap (); 
        return soapService.IMTimeStampSearch(email); 
    } 
}

And here is my test class:  
@isTest(SeeAllData=true) 
Global class TestIncidentManagerCallout{ 
static testMethod void Test(){ 
string email = GetUserInfo.GetCurrentUserEmail(); 
Test.setMock(WebServiceMock.class, new IncidentManagerMock()); 
IncidentManager.ArrayOfSHSHresult result = IncidentManagerCallout.GetIMData(email); 

}
My sytax is not getting an error when I check it via my javascript button - however, when I click the button which executes it - it throws an unexpected token { error.  What am I doing wrong?

//Subregion consideration 
    If ({!ISPICKVAL(Account.Sub_Region__c, 'NA')
      } ||(!ISPICKVAL(Account.Sub_Region__c, 'SA')
      } ||(!ISPICKVAL(Account.Sub_Region__c, 'EU')
      } ||(!ISPICKVAL(Account.Sub_Region__c, 'ME')
      } ||(!ISPICKVAL(Account.Sub_Region__c, 'CN')
      } ||(!ISPICKVAL(Account.Sub_Region__c, 'AS')
      } ||(!ISPICKVAL(Account.Sub_Region__c, 'AN')
      }) {
//there is a bunch more code here.......if......blah blah
//Subregion consideration 
     } else
       alert('A valid subregion is required for customer conversion.');
How can I fix this syntax?  I want the first two lines evaluated first followed by the last two lines....another pair of eyes would be greatly appreciated.

ISCHANGED((AccountId) = True || (AccountId) <> '' ) &&
Address_Line_1__c <> '' OR
ISCHANGED((Account.LCL_Account_Name__c) = True || (Account.LCL_Account_Name__c) <> '')
&& LCL_Address_Line_1__c <> ''
How can I get around the aggregrate query error? When I tried taking out the For loop- the execution then failed. Is there a better way to do it?

global class Batch_ExpDate_PricIn implements Database.Batchable<sObject>,Database.Stateful
{
   global Database.QueryLocator start(Database.BatchableContext BC)
   {
        string manualExpStr = 'Manually Expired'; //Correct Status -11/2/16 MT
        string expiredStr = 'Expired'; 
        
        string query= 'select Id,RecordTypeId,RecordType.Name,Par_Status__c,Effective_date__c,Expiration_Date__c,(select Id,Expiration_Date_Change_To__c,Effective_date__c from Pricing_Inputs__r) from Price_Authorization_Request__c where Par_Status__c !=:manualExpStr  and Par_Status__c !=:expiredStr';
             return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<Price_Authorization_Request__c> Parlist) {
            
       if(Parlist != null && !Parlist.isEmpty())
       {
              Map<String,string> maprecTypewithId = new Map<String,String>();
           List<Price_Authorization_Request__c> listPARToUpdate = new List<Price_Authorization_Request__c>();
           for(RecordType rec : [select id,Name from recordType where SObjectType = 'Price_Authorization_Request__c']) //-->system does not like this
           {
               maprecTypewithId.put(rec.Name,rec.id);
           }
           
           
           for(Price_Authorization_Request__c parObj : Parlist)
           {
            if(parObj.Pricing_Inputs__r != null && !parObj.Pricing_Inputs__r.isEmpty())
            {
                 Integer count = 0;
                 for(Pricing_Input__c PrcInputObj : parObj.Pricing_Inputs__r)
                 {
                    
                    if(PrcInputObj.Expiration_Date_Change_To__c != null && PrcInputObj.Expiration_Date_Change_To__c < system.today())
                    {
                        count = count + 1;
                    }
                 }
                 
                 if(count ==(parObj.Pricing_Inputs__r).size())  
                 {
                    parObj.Par_Status__c = 'Expired'; 
                  //  parObj.Expiration_Date__c=Date.valueOf(System.Today());
                    if(parObj.RecordType.Name == 'Standard PAR' && maprecTypewithId.get('ReadOnlyStandard PAR') != null)
                      parObj.RecordTypeId = maprecTypewithId.get('ReadOnlyStandard PAR');
                    else if(parObj.RecordType.Name == 'Formula PAR' && maprecTypewithId.get('ReadOnlyFormula PAR') != null)
                      parObj.RecordTypeId = maprecTypewithId.get('ReadOnlyFormula PAR');
                    listPARToUpdate.add(parObj);
                 }
            }
              
           }
           
           if(!listPARToUpdate.isEmpty())
               update listPARToUpdate;
       }
   }
    
    global void finish(Database.BatchableContext BC)
    {}
 }
 I've tried to put my query directly in a list and then loop through the list but I'm getting an error invalid value type list for list.

Map<String,string> maprecTypewithId = new Map<String,String>();
           List<Price_Authorization_Request__c> listPARToUpdate = new List<Price_Authorization_Request__c>([select id,Name from recordType where SObjectType = 'Price_Authorization_Request__c']);
           for(RecordType rec : listPARToUpdate)
           {
               maprecTypewithId.put(rec.Name,rec.id);
           }

However, If I try it this way - I get the aggregrate query FOR loop error (due to large recrod set) 

Map<String,string> maprecTypewithId = new Map<String,String>();
           List<Price_Authorization_Request__c> listPARToUpdate = new List<Price_Authorization_Request__c>();
           for(RecordType rec : [select id,Name from recordType where SObjectType = 'Price_Authorization_Request__c'])
           {
               maprecTypewithId.put(rec.Name,rec.id);
           }

What is the best way to achieve this - without exceeding governor limits?
Id 01pF000000452WnIAI = Database.executeBatch(new Batch_ExpDate_PricIn(), 190);

The id referenced is correct.  What am I doing wrong here?  
global void execute(Database.BatchableContext BC, List Parlist) {

if(Parlist != null && !Parlist.isEmpty())
{
Map maprecTypewithId = new Map(); 
List listPARToUpdate = [select id,Name from recordType where SObjectType = 'Price_Authorization_Request__c'];
for(RecordType rec : listPARToUpdate )
{
maprecTypewithId.put(rec.Name,rec.id);
}

How can I avoid my illegal assignment of lists? Also, where would I specify a batchable size of 190?
What is wrong with the syntax in this statement?  I have a syntax error on the first if statement line saying unexpected token:

public pagereference savesamp()
        //Prevent user from entering a sample request using an Inactive account or one without an address line 1 -07/19/16 MT
    {    
        if({!ISPICKVAL(Account.Account_Status__c, "Inactive")} || {!Account.Address_Line_1__c} == '')
        
        ApexPages.Message SampleNotAllowed = new ApexPages.Message(ApexPages.Severity.ERROR,'Account must be active and contain           an address in order to raise a sample request.'); 
        ApexPages.addMessage(SampleNotAllowed);
        return null;

try{
          
        upsert samObj;
        
      }Catch(Exception ex)
      {
         ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,ex.getMessage());
         ApexPages.addMessage(errorMessage);
        return null;
      }
     return new pagereference('/'+samObj.id);
    }