Loading
Visual Studio Code Based Modeler for Consumer Goods Cloud
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Model Picture Capturing

          Model Picture Capturing

          The images captured with the Consumer Goods offline mobile app are stored in the same structure as attachment files and a thumbnail is created. The database stores only the path where the image is stored as a BLOB string. The images are deleted if you delete or discard the record that contains the BLOB string with the path.

          Required Editions

          Available in: Enterprise, Performance, and Unlimited Editions
          User Permissions Needed
          To model picture capturing Customizer, Admin
          1. Add an attachment list item with simple properties to the attachment List Object. The blobtable attribute in SimpleProperty element is required at run time to determine the correct path structure in the file system.
            When you take a picture, the Framework API Facade.getPictureAsync() loads the device's default camera and fetches the image URI. An object is passed as the parameter to the API with the quality and encodingType properties.

            To define the quality of the captured image, specify a number between 0 and 100. Default is 20. 100 provides full resolution with no loss from file compression and 0 renders a low-resolution image. If no value is specified, it takes the default value. To define the encoding type of the returned image, specify JPEG or PNG. Default is JPEG.

            The API returns a promise. If you specify invalid input parameters, the promise is rejected. The result will be the path of the image taken.
          2. Assign the path value to the simple property of type DomBlob (mediaPath, for example).
            When you tap Save, the list item is stored and the image is copied to the appropriate attachment path. If you tap Discard, the app removes the picture.
          3. Save your changes.
          Example
          Example LoCallAttachments list object sample code:
          <ListObject name="LoCallAttachments" generateLoadMethod="true" schemaVersion="1.1">
            <DataSource name="DsLoCallAttachments" />
            <Item objectClass="LiCallAttachments" />
            <Methods>
              <Method name="beforeSaveAsync" />
              <Method name="afterSaveAsync" />
              <Method name="afterLoadAsync" />
              <Method name="beforeLoadAsync" />
              <Method name="afterDoValidateAsync" />
              <Method name="beforeDoValidateAsync" />
              <Method name="loadAsync" />
              <Method name="saveAsync" />
              <Method name="calculateDistance" />
              <Method name="getCameraSettings" />
              <Method name="capturePicture" />
          <!–-details skipped for brevity-->
            </Methods>
          </ListObject>

          LiCallAttachments list item sample code:

          <ListItem name="LiCallAttachments">
            <SimpleProperties>
          <!–-details skipped for brevity-->
              <SimpleProperty name="attachmentTextPKey" type="DomPKey" dataSourceProperty="attachmentTextPKey" />
              <SimpleProperty name="attachmentText" type="DomText" dataSourceProperty="attachmentText" />
              <SimpleProperty name="attachmentBlobPKey" type="DomPKey" dataSourceProperty="attachmentBlobPKey" />
              <SimpleProperty name="attachmentBlob" type="DomBlob" dataSourceProperty="attachmentBlob" blobTable="ClbAttachmentBlob" blobPKeyField="attachmentBlobPKey" />
            </SimpleProperties>
          </ListItem>

          This code example shows how you can add an attachment item to the list of attachments. The method takes the current customer and path from getPictureAsync() as its parameters.

          * @function capturePicture
           * @this LoCallAttachments
           * @kind TODO_ADD_BUSINESS_OBJECT_TYPE
           * @async
           * @namespace CORE
           * @param {Object} cameraSettings
           * @param {DomBool} openGallery
           * @returns promise
           */
          function capturePicture(cameraSettings, openGallery){
              var me = this;
              ///////////////////////////////////////////////////////////////////////////////////////////////
              //                                                                                           //
              //               Add your customizing javaScript code below.                                 //
              //                                                                                           //
              ///////////////////////////////////////////////////////////////////////////////////////////////
              
          var promise;
          
          if(openGallery == "1"){
            promise = Facade.getPictureFromLibraryAsync(cameraSettings);
          }
          else{
            promise = Facade.getPictureAsync(cameraSettings);
          }
          
          // Do something with the image url provided
          // In Android, example imageURI = file:///storage/emulated/0/Android/data/cgcloud.ngm.com/cache/1395835803979.jpg
          // In ios, example imageURI = file:///var/mobile/Applications/7D13E650-ACE8-43A0-B23B-1825A5231C2D/tmp/cdv_photo_002.jpg 
          // JSON will be in this formart {"width":1024,"height":768,"path":"BpaAttachmentBlob/0020000000002jot.jpg"}
          
              ///////////////////////////////////////////////////////////////////////////////////////////////
              //                                                                                           //
              //               Add your customizing javaScript code above.                                 //
              //                                                                                           //
              ///////////////////////////////////////////////////////////////////////////////////////////////
          
              return promise;
          }
           
          Loading
          Salesforce Help | Article