0

what is initial submission in approval process?

Without clicking on submit for approval can i send it to approval process? Can u please share steps

2
  • You are able to use apex and other programmatic methods to submit a record for approval, however, without more specific data on the use case in the question, you wont receive a quality answer. Commented Aug 27, 2015 at 14:01
  • Can you please elaborate on what exactly is the requirement ? As mentioned in above comment, you can do it from apex as well.
    – Dave
    Commented Aug 27, 2015 at 14:52

2 Answers 2

1

Initial submission actions are the actions that occur when a user first submits a record for approval. By default, an action to lock the record runs automatically on initial submission. Initial submission actions can include any approval actions such as email alerts, field updates, tasks, or outbound messages. For example, an initial submission action can update a custom approval status field to “In Progress.”

1

You can canll approval process from trigger. You can write below code in class and can call this function from trigger.

@future public static void approvalInit(String objType, String id, String comment){ sObject obj; Schema.SObjectType targetType = Schema.getGlobalDescribe().get(objType); if (targetType == null) { // throw an exception }else{ obj = Database.query(getQuery(targetType.newSObject(), null) + ' WHERE Id = \'' + id + '\''); } Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest(); req.setComments(comment); req.setObjectId(obj.Id); Approval.ProcessResult result; try{ // submit the approval request for processing result = Approval.process(req); }catch(Exception e){ // display if the reqeust was successful System.debug('No approval process has been setup yet.'); } }

public static String getQuery(sObject obj, String mergedFields){

    Map<String, Schema.SObjectField> fldObjMap = obj.getSObjectType().getDescribe().fields.getMap();
    //The values from the map of fields
    List<Schema.SObjectField> fldObjMapValues = fldObjMap.values();
    String query = '';
    String restricted = 'BillingLongitude,PersonOtherLongitude,ShippingLongitude,BillingLatitude,PersonOtherLatitude,'+
        'ShippingLatitude,PersonMailingLatitude,PersonMailingLongitude,MailingLatitude,MailingLongitude,OtherLatitude,OtherLongitude,'+
        'LastReferencedDate,';
    //Add field names to string
    for(Schema.SObjectField s : fldObjMapValues){
        String fn = s.getDescribe().getName();
        if(restricted.indexOf(fn) == -1){
            query += fn+',';
        }
    }
    System.debug('======================================= query: ' + query);
    if(mergedFields != null){
        query = 'SELECT ' + query + mergedFields + ' FROM ' + obj.getSObjectType().getDescribe().getName() + ' ';
    }else{
        query = 'SELECT ' + query.substring(0,query.lastIndexOf(',')) + ' FROM ' + obj.getSObjectType().getDescribe().getName() + ' ';
    }
    return query;
}

Not the answer you're looking for? Browse other questions tagged .