• Kashyap Joshi
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 21
    Replies

I am trying to get Order status in Einstein chatbot but not getting

User-added image

I have added Apex class here 

public with sharing class GetOrderStatus {

  public class OrderOutput {
    @InvocableVariable(required=true)
    public String sOrderStatus;
      public String sOrderName;
  }

  public class OrderInput {
    @InvocableVariable(required=true)
    public String sOrderNumber;
  }
   

  @InvocableMethod(label='Get Order Status')
  public static List<OrderOutput> getOrderStatus(List<OrderInput> orderInputs) {
    Set<String> orderNumbers = new Set<String>(); 

    // Get the order numbers from the input
    for (OrderInput orderInput : orderInputs) {
      orderNumbers.add(orderInput.sOrderNumber);
    }

    // Get the order objects from the set of order numbers
    List<OrderItemSummary> orders = 
        [SELECT OrderSummary.OrderNumber,Name,Quantity,TotalAmtWithTax,Status FROM OrderItemSummary where OrderSummary.OrderNumber =: orderNumbers];
      //[SELECT OrderNumber, Status FROM OrderSummary where OrderNumber =: orderNumbers];
      //System.debug('order' +orders);
      
    // Create a map of order numbers and order status values
    Map<String, String> mapNameStatus = new Map<String, String>(); 
    if (orders.size() > 0) {
        for (OrderItemSummary order : orders) {
          mapNameStatus.put(order.OrderSummary.OrderNumber, order.Status);
        }
    }
    
    // Build a list of order status values for the output
    List<OrderOutput> orderOutputs = new List<OrderOutput>();
    for (OrderInput orderInput : orderInputs) {
      OrderOutput orderOutput = new OrderOutput();
      
      // Do we havorderOutpute a status for this order number?
      if (mapNameStatus.containsKey(orderInput.sOrderNumber)) {
          // If so, then add the status
          orderOutput.sOrderStatus = mapNameStatus.get(orderInput.sOrderNumber);
      } else {
          // If not, then add an unknown status value
          orderOutput.sOrderStatus = 'Order not found';
      }
      orderOutputs.add(orderOutput);
    }

    return orderOutputs;    
  }
}

Hi All,

I am trying to authorize an org on visual code but   I am getting the below error.

SFDX: Authorize an Org failed to run

 sfdx force:auth:web:login --setalias JFFDdev --instanceurl https://test.salesforce.com --setdefaultusername
ERROR running auth:web:login:  spawn UNKNOWN


sfdx force:auth:web:login --setalias JFFDdev --instanceurl https://test.salesforce.com --setdefaultusername
 ended with exit code 1

I am trying to get Order status in Einstein chatbot but not getting

User-added image

I have added Apex class here 

public with sharing class GetOrderStatus {

  public class OrderOutput {
    @InvocableVariable(required=true)
    public String sOrderStatus;
      public String sOrderName;
  }

  public class OrderInput {
    @InvocableVariable(required=true)
    public String sOrderNumber;
  }
   

  @InvocableMethod(label='Get Order Status')
  public static List<OrderOutput> getOrderStatus(List<OrderInput> orderInputs) {
    Set<String> orderNumbers = new Set<String>(); 

    // Get the order numbers from the input
    for (OrderInput orderInput : orderInputs) {
      orderNumbers.add(orderInput.sOrderNumber);
    }

    // Get the order objects from the set of order numbers
    List<OrderItemSummary> orders = 
        [SELECT OrderSummary.OrderNumber,Name,Quantity,TotalAmtWithTax,Status FROM OrderItemSummary where OrderSummary.OrderNumber =: orderNumbers];
      //[SELECT OrderNumber, Status FROM OrderSummary where OrderNumber =: orderNumbers];
      //System.debug('order' +orders);
      
    // Create a map of order numbers and order status values
    Map<String, String> mapNameStatus = new Map<String, String>(); 
    if (orders.size() > 0) {
        for (OrderItemSummary order : orders) {
          mapNameStatus.put(order.OrderSummary.OrderNumber, order.Status);
        }
    }
    
    // Build a list of order status values for the output
    List<OrderOutput> orderOutputs = new List<OrderOutput>();
    for (OrderInput orderInput : orderInputs) {
      OrderOutput orderOutput = new OrderOutput();
      
      // Do we havorderOutpute a status for this order number?
      if (mapNameStatus.containsKey(orderInput.sOrderNumber)) {
          // If so, then add the status
          orderOutput.sOrderStatus = mapNameStatus.get(orderInput.sOrderNumber);
      } else {
          // If not, then add an unknown status value
          orderOutput.sOrderStatus = 'Order not found';
      }
      orderOutputs.add(orderOutput);
    }

    return orderOutputs;    
  }
}

Hi All,

I am trying to authorize an org on visual code but   I am getting the below error.

SFDX: Authorize an Org failed to run

 sfdx force:auth:web:login --setalias JFFDdev --instanceurl https://test.salesforce.com --setdefaultusername
ERROR running auth:web:login:  spawn UNKNOWN


sfdx force:auth:web:login --setalias JFFDdev --instanceurl https://test.salesforce.com --setdefaultusername
 ended with exit code 1