• Sagar104
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 11
    Replies
Hi All

Im getting the below code error (A problem with the OnClick JavaScript for this button or link for the below code. aX63....(salesforce id) is not defined) for the execute javascript on the button 

Original Code :

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 

if('{!$Profile.Name}' == '1234') { 
alert("This feature is reserved for Administrators and Managers, Please Contact your supervisor..."); 
}else{ 
var r = confirm("Are you sure you want to reject this request? It will be removed from the Events Calendar."); 
if(r == true){ 
try{ 
var result; 
result = sforce.apex.execute("TechEvetLineRejectClass", "LineReject",{TELID:"{!Technician_Event_Lines__c.Id}"}); 
alert("Successfully Calendar Event Deleted... "); 
window.location.reload(); 

} catch(ex) { 
alert({!Technician_Event_Lines__c.Id}); 
alert(ex); 


}




SECONDLY i need to add a logic here that 
if Timeoff(a field with date value) is Less than todays date , Then need to throw an alert and the button on click should not work.

Kindly help
Hi All

Kindly help me here, i have an apex class for webservice, i require the test class to be completed.

The APEX CLASS is as follows;

global class Sendxxx {
    private static String workOrderId ;
    private static String workOrderStatus ;
    webService static void postToSAP(String orderStatus, String woId) { 
   system.debug('orderStatus'+orderStatus);
      If(orderStatus =='Complete' || orderStatus =='Partially Completed')
       { 
       system.debug('orderStatus'+orderStatus);
        workOrderId  = woId;
          workOrderStatus = orderStatus.tolowercase();
          //workOrderStatus = orderStatus;
        getAndParse();
        
    }
    else
    {
      system.debug('orderStatus'+orderStatus);
     }
      }
    
  global static void getAndParse() {
    
        HttpRequest req = new HttpRequest();
  
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        //String strname = 'Username';
       // String strpwd= 'pwd';
        //String SessionId = Userinfo.getSessionId();
        String strURL = System.URL.getSalesforceBaseURL().toExternalForm();
        req.setEndpoint('https://elastic.snaplogic.com:443/api/1/rest/slsched/feed/xxxx/xx/xxxrviceMax/SVMXC_SumEstimatedTime_Task?work_order_id='+workOrderId+'&state='+workOrderStatus);
        req.setHeader('authorization','Bearer owhBgvxxxxxxz');
        req.setTimeout(120000);
        req.setHeader('cache-control', 'no-cache');
        req.setMethod('GET');
        
        JSONGenerator gen = JSON.createGenerator(true);
            gen.writeStartArray();
            gen.writeStartObject();
            gen.writeStringField('SVMXC__Service_Order__c', workOrderId );
           gen.writeStringField('SVMXC__Order_Status__c',workOrderStatus );
            gen.writeEndObject();              
          gen.writeEndArray();
          String jsonOrders = gen.getAsString();
           System.debug('jsonOrders: ' + jsonOrders);
          req.setHeader('Content-Type', 'application/json');
          req.setHeader('Accept-Encoding', 'gzip');
           req.setBody(jsonOrders);
            req.setCompressed(true); // otherwise we hit a limit of 32000 
        try {
            res = http.send(req);
            
            if (res.getStatusCode() == 200 ) {
            
             System.debug('CALLOUOT SUCCESSFUL');
             System.debug('RESPONSE FROM CPQ 1111--->'+res.toString());
             System.debug('RESPONSE BODY--->'+res.getBody());
            }
        }             
        catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug('RESPONSE FROM CPQ'+res.toString());
        }
        
 }
 }
Assigining permission sets by apex trigger
Requirement : There are some fields on the object , we need to grant permissions to edit  based on the picklist values.( i have written validations rules at first but didnt work)
Scenerio:I ve made all the fields of the object read only in Profile. then created permission set to the fields for edit permission. now based on the profile name I want to assign the same permission set to the user though the trigger.but it is not getting assigned. kindly assist what changes should be done?

Trigger Attached

trigger PSA_on_WO on Service_Order__c (before update)
    {
    if(Trigger.isBefore)
    {
      if(Trigger.isUpdate)
      {
          for ( Service_Order__c wo : trigger.new)
             {
                  id id1 = userinfo.getUserId();
                 id id2 = userinfo.getProfileId();
                String pf=[Select Id,Name from Profile where Id=:id2].Name;
              
              PermissionSetAssignment[] psa1 = new List<PermissionSetAssignment>();

              system.debug('profile ----> '+pf);
              system.debug('id1 ----> '+id1);
              system.debug('order status--->'+wo.Order_Status__c);
              system.debug('order type--->'+wo.Order_Type__c);
                  if(wo.Order_Status__c.equalsIgnoreCase('Draft') 
                           && wo.Order_Type__c.equalsIgnoreCase('FS'))
                 {
                       if(pf=='profile1' || pf == 'profile2' || pf=='profile3')
                    {
                         PermissionSetAssignment psa = new PermissionSetAssignment(PermissionSetId = '0PS3C0000004GLCWA2',AssigneeId = id1);
                 psa1.add(psa);        
                                   system.debug('permission set id----->' +psa.PermissionSetId);
                          system.debug('assignid id----->' +psa.AssigneeId);
                    }
                    else if(pf=='profile4')
                    {
                    PermissionSetAssignment psa = new PermissionSetAssignment(PermissionSetId = '0PS3C0000004GLW',AssigneeId = id1);
                     psa1.add(psa); 
                    }  
              
                   }
             insert psa1;
        }
    }
    }
}
Need to create a new report type has been requested linking  two objects "X" & "Y" . This report should contain all "X" objects as well as the fields associated to them by a common Sales Order number.
The link between these two objects should be as follows:
Order Number ("X") = SAP ID ("Y")
NOTE: Order Number will have 3 leading zeroes where as SAP ID will not, some logic needs to applied through the report link to remove these zeroes to ensure the link works properly.

HOW do i achieve it.. kindly suggest as im new to it
Im a newbie , On click of a custom button i need message to popup like xyz , but it shoul have ok or cancel.. If ok then it should proceed to the  operation , if cancell then just no action