How to get URI Params in MuleSoft Anypoint Studio?

Listener Configuration:



Select with URI Params Configuration:


How to convert to JSON in MuleSoft using Data Weave 2.0?



Increase length of custom text field when the field has data in Salesforce

You won't have a problem with increasing the size of a text field.

If you decrease the size of a text field, the data will be truncated to the new field size. You will receive an email.


How to get rows count from CSV File and check in Choice component in MuleSoft?

Sample Flow:



Set Variable Configuration:




nodejs “npm ERR! code SELF_SIGNED_CERT_IN_CHAIN”

If you face "nodejs “npm ERR! code SELF_SIGNED_CERT_IN_CHAIN”" error, execute the below command

npm set strict-ssl false


This will disable strict ssl-mode and you will not get the error.

Canvas App in Salesforce

Canvas enables you to easily integrate a third-party application in Salesforce. Canvas is a set of tools and JavaScript APIs that you can use to expose an application as a canvas app. This means you can take your new or existing applications and make them available to your users as part of their Salesforce experience.

Canvas App Previewer
Canvas App Previewer is a development tool that lets you see what your canvas apps will look like before you publish them.

The third-party app that you want to expose as a canvas app can be written in any language. The only requirement is that the app has a secure URL (HTTPS).

apex:canvasApp is the tag to use in Visualforce page.

How to schedule to read a file and import into Salesforce using MuleSoft?

Below configuration will  read a file and import into Salesforce using MuleSoft for every two minutes.

Flow:



Scheduler Configuration:



Read File Configuration:




Transform Message Configuration:



Logger Configuration:



Create Bulk Configuration:



Logger Message from Console:



How to import the RAML file from Anypoint Platform Runtime manager by downloading the RAML?

1. Go to the Runtime Manager.


2. Select the environment.

3. Select the project.

4. Click on the .zip file to download the project.


5. Extract the downloaded file.

6. Create new Mule project. Select Browse Files.


7. Locate the RAML file from the downloaded zip.

There's a problem saving this record. You might not have permission to edit it, or it might have been deleted or archived. Contact your administrator for help

When you face "There's a problem saving this record. You might not have permission to edit it, or it might have been deleted or archived. Contact your administrator for help" issue, check the following

1. Check whether the user's profile have Edit access on this object.

2. Check whether the user have proper sharing rules or OWD is public read write to edit the other users records. If the record is owned by user in higher hierarchy, then the user won't be able to update the record.

3. Set debug log and find whether 1 and 2 and impacted on other objects through triggers.

How to remove all non numbers using Apex in Salesforce?

Sample code:


  1. String invalidNumbers = '[^0-9]';  
  2. String str = 'abcd123456789xyz';  
  3. system.debug( 'Only numbers - ' + str.replaceAll( invalidNumbers, '' ) );  

Output:


How to create a API specification and deploy in Anypoint Platform?

1. Go to the Design Center.


2. Click API Specification.


3. Enter Project Name, select Start with API designer and click Create button.


4. Use the below RAML.

  1. #%RAML 1.0  
  2. baseUri: https://anypoint.mulesoft.com/mocking/api/v1/links/d69cd01b-2827-42cc-8e1e-ec2a93c6970c/ #   
  3. title: flights  
  4. /flights:  
  5.  get:  
  6.   queryParameters:  
  7.     destination:  
  8.      required: false  
  9.      enum:  
  10.       - SFO  
  11.       - LAX  
  12.       - CLE  
  13.   responses:  
  14.     200:  
  15.       body:  
  16.         application/json:  
  17.          example:   
  18.           [{"ID":1,  
  19.          "code":"ER38sd",  
  20.          "price":400,  
  21.          "departureDate":"2016/03/20",  
  22.          "origin":"MUA",  
  23.          "destination":"SFO",  
  24.          "emptySetats":0,   
  25.          "plane": {"type":"Boeing 737""totalSeats": 150}},  
  26.          {"ID":2,  
  27.          "code":"ER45if",  
  28.          "price":345.99,  
  29.          "departureDate":"2016/02/11",  
  30.          "origin":"MUA",  
  31.          "destination":"LAX",  
  32.          "emptySeats": 52,  
  33.          "plane":{"type":"Boeing 777""totalSeats": 300}  
  34.          }]  
  35.   
  36.  post:  
  37.   displayName: Add the flight  
  38.   body:  
  39.     application/json:  
  40.      example:  
  41.        {"ID":1,  
  42.          "code":"ER38sd",  
  43.          "price":400,  
  44.          "departureDate":"2016/03/20",  
  45.          "origin":"MUA",  
  46.          "destination":"SFO",  
  47.          "emptySetats":0,   
  48.          "plane": {"type":"Boeing 737""totalSeats": 150}}  
  49.   responses:  
  50.     201:  
  51.       body:  
  52.         application/json:  
  53.          example:  
  54.            {"Message":"Flights added {but not really)"}  
  55.   
  56.  /{ID}:  
  57.   get:  
  58.    responses:  
  59.      200:  
  60.        body:  
  61.          application/json:  
  62.           example:  
  63.             {"ID":1,  
  64.            "code":"ER38sd",  
  65.            "price":400,  
  66.            "departureDate":"2016/03/20",  
  67.            "origin":"MUA",  
  68.            "destination":"SFO",  
  69.            "emptySetats":0,   
  70.            "plane": {"type":"Boeing 737""totalSeats": 150}}  

5. Select Publish to Exchange.


6. Enter a name and click Publish button.

7. Go to the API Manager.


8. Click "Manage API" and select "Manage API from Exchange".


9. Save Manage API from Exchange


10. Select the Runtime version. Enter unique Proxy application name. Click Deploy.


11. Get the Proxy URL.


12. Add /console and open it.






How to connect to MySQL table and transform it to JSON using MuleSoft?

1. Create a simple project as below.



2. Listener Configuration is below


3. Select configuration.

Note:
a. Download MySQL connector - https://dev.mysql.com/downloads/connector/j/.
b. Select Local file and add it.
c. The password is also mule.


4. Transform Configuration.

a. Create a json file with the below.

  1. [  
  2. {  
  3.     "ID":1,  
  4.     "code1":"test1",  
  5.     "code2":"testing1",  
  6.     "airlineName":"testing1",  
  7.     "toAirport":"testing1",  
  8.     "fromAirport":"testing1",  
  9.     "takeOffDate":"2011/11/11",  
  10.     "price":100,  
  11.     "planeType":"testing1",  
  12.     "setatsAvailable":10,  
  13.     "totalSeats":250  
  14. },  
  15. {  
  16.     "ID":2,  
  17.     "code1":"test",  
  18.     "code2":"testing",  
  19.     "airlineName":"testing",  
  20.     "toAirport":"testing",  
  21.     "fromAirport":"testing",  
  22.     "takeOffDate":"2010/10/10",  
  23.     "price":100,  
  24.     "planeType":"testing",  
  25.     "setatsAvailable":10,  
  26.     "totalSeats":250  
  27. }  
  28. ]  

b. While adding metadata type, use the json file created in above step.

c. Drag and drop to match.



5. Logger Configuration.


6. Run the application.

Output:

Open http://localhost:8081/db in the browser to view the result from the table