Can't access to a Docusign action json node in an omniscript - salesforce

The Docusign action is in the json node everytime the user click on the action, so i'm trying to reference the status of the action to add a validation but I can't access to the json node.
This is the json node:
{
"DS_SignatureAction":[
{
"status":"In Process",
"envelopeId":"a079a5ef-ae6d-4a6f-9483-583a881e826a"
},
{
"status":"Completed",
"envelopeId":"2e679aed-bc09-4cbf-830b-2b16cb1eb28b"
}
]
}
And I tried with:
%DS_SignatureAction|1:status%, %DS_SignatureAction:status%, %DS_SignatureAction%
But no one of these work, so anyone know if it is a bug or what is happening? Thanks

Related

Use data from graphql response in React

I guess this is a simple issue, but I am stuck here for a while, so any advice may be helpful!
I have a react app and I am calling a GraphQL api (with apollo). Inside an arrow function component I have:
const [executeQuery, { data }] = useLazyQuery(GET_ALL_TASKS);
const findId = (step) => {
executeQuery({
variables: {
"query": {
"state": "CREATED",
"taskDefinitionId": "something"
}
}
})
}
The query is successful and in the browser inspect panel I get this as the graphql response:
{
"data" : {
"tasks" : [ {
"id" : "2251",
"name" : "some_name",
"__typename" : "Task"
} ]
}
}
In my code I want to use the retrieved id. How can I isolate the id from the response? When I am trying to access the data I get an undefined error.
Thank you!
Not sure why you are wrapping your executeQuery in a function.
The data will be part of the response so you can get it like this:
const {data, loading} = executeQuery({
variables: {
"query": {
"state": "CREATED",
"taskDefinitionId": "something"
}
}
})
// may also need to check for the error state
if(loading){
console.log("Loading...")
}else{
/// the ids seem to be an array of objects
const ids = data.tasks.map((task)=> task.id)
console.log(ids)
}
For anyone who may have the same problem, I realized it is a caching error happening in apollo client. I couldn't figure out the solution. However, I temporarily solved it by downgrading the apollo client dependency to version 3.2.5

AWS Amplify - How to query GraphQL when some of the data is undefined

When using the AWS AppSync console, I can run this query and get a return...
listAccounts {
items {
name
cameras {
items {
name
}
}
}
}
}
But when I run the same query from inside my react app using
await API.graphql({ query: queries.listAccounts })
I get an error...
"Validation error of type FieldUndefined: Field 'items' in type 'Query' is undefined # 'items'"
My issue is that an Account will not always have a camera, in which case I would like to be able to get the response and still display the camera data. Can anyone help me out here. Is there some way to 'allow' undefined?

how to add an attachment to the sendEmail quickaction apI through lightning component?

i need to populate the attachment on send email lightning quick action api. i can able to set the
subject to the email quick action, but i need to add the attachment to the email. How can i send the
attachment from apex to lightning component
how to return the attachment from apex to lightning component. and how to add to HtmlBody parameter for lightning quick action api?
You need do as follows
1. Create Lightning Flow action to trigger Apex code.
2. Using apex code trigger email and attach attachments also.
I am able to attach using this it might help you:
var actionAPI = component.find("quickActionAPI");
//var targetFields = {Subject:{value:"Sets by lightning:quickActionAPI component 3"}, HtmlBody:{value:'HTML BODY'}};
var targetFields = {
Subject:{
value:"Sets by lightning:quickActionAPI component"
},
HtmlBody:{
value:'HTML BODY'
},
ToAddress:{
value:'devid#testgmail.com'
},
ContentDocumentIds:{
value:['0691D000001cgXXXX']
}
};
var args = {actionName: "Quote.SendEmail", entityName: "Quote", targetFields: targetFields};
actionAPI.getAvailableActions(args).then(function(result){
//All available action fields shown for Log a Call
console.log('##getAvailableActions#result==', JSON.stringify(result));
}).catch(function(e){
console.error(e.errors);
if(e.errors){
//If the specified action isn't found on the page, show an error message in the my component
}
});
actionAPI.getAvailableActionFields(args).then(function(result){
//All available action fields shown for Log a Call
console.log('##getAvailableActionFields#result==', JSON.stringify(result));
}).catch(function(e){
console.error(e.errors);
if(e.errors){
//If the specified action isn't found on the page, show an error message in the my component
}
});
actionAPI.setActionFieldValues(args).then(function(response){
console.log('##WORKING#setActionFieldValues##', response, args);
//actionAPI.invokeAction(args);
console.log('##WORKING#setActionFieldValues##');
}).catch(function(e){
console.error(e.errors);
});
More methods available here please check: https://developer.salesforce.com/docs/atlas.en-us.case_feed_dev.meta/case_feed_dev/quickaction_api.htm

How can we set context variables for IBM Watson from backend

I want to pass some values to frontend in form of context variables in IBM Watson through my Node app. How can I achieve it?
I tried to add the value I want to add to current context variable object and sent that back. Still no help. Is there any way I can do it?
Edit:
Right now, I am adding the required value as a new key-value pair to the context object from Node app as follows.
...
let user_name = "MJ"
context.user_name = user_name
response.send({
output: output,
context: JSON.stringfy(context)
})
...
And in Watson Console, in one of the dialogue nodes I have used like,
Hey $user_name, How are you?
But the output I am getting is,
Hey , How are you?
I can see user_name value in the context object, but I can't use it in the way I mentioned above. Is there any other way to do so?
Any help is appreciated. Thanks in advance!
I was having the same problem. My solution was changing the code when you call the IBM server and request .json:
...
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text,
context: {username : variable},
...
The username I set in Watson Assistant as well as a context, the variable I used a function to get the name though Query (Because in my application, I am calling the chatbot though an IFrame.), but you can use any variable set on javascript.
You can add any value to the Context object, which can be accessed in your Node.JS app and if you send that value to the front-end, then it should be accessible in the UI as well.
Below I've mentioned a sample welcome response from Conversation service. You can access the Context object from the response of Conversation service and add a new key-value pair to that object. In the response, you'll see that I'm accessing a context variable username that has the value MJ, which has been added dynamically to the context.
`
{
"intents": [],
"entities": [],
"input": {
"text": ""
},
"output": {
"text": ["Hello MJ! How can I help you today?"],
"nodes_visited": ["Conversation Start"],
"log_messages": []
},
"context": {
"username": "MJ",
"conversation_id": "5835fa3b-6a1c-4ec5-92f9-22844684670e",
"system": {
"dialog_stack": [{
"dialog_node": "Conversation Start"
}],
"dialog_turn_counter": 1,
"dialog_request_counter": 1,
"_node_output_map": {
"Conversation Start": [0]
}
}
}
`
Now to update the context, fetch the response and add a new key-value pair
`
var convResponse = <responseObj from Conversation call>;
var context = convResponse.context;
//add new value to context
context["new_key"] = "new value";
`
Now the next call that you make to Conversation, use this updated context instead of the context you received from the previous call. You can send back the response from Conversation to the front-end as well which can then be shown to the user.
var payload = {
assistantId: assistantId,
sessionId: req.body.session_id,
context: {
skills: {
"main skill": {
user_defined: {
username: 'John Doe'
}
}
}
},
input: {
message_type: 'text',
text: "blah",
},
};
works for me. Seen here: https://medium.com/#pranavbhatia_26901/watson-assistant-v2-context-sharing-3ca18626ed0d

Google Calendar API. Patching sharedExtendedProperty for events

I have created event in my Google calendar. Most interesting part is:
{
// some event data;
"extendedProperties": {
"shared": {
"cases_1": "1",
"cases_2": "2"
}
}
}
Right now I need to PATCH existing event. In extendedProperties I do not need "cases_1":"1" any more. So I use developers endpoint to patch it. The PATCH request body is:
{
"extendedProperties": {
"shared": {
"cases_2": "2"
}
}
}
In response I see my both shared fields. How must my request body look like to remove from extendedProperties shared cases_1 field?
Try adding the line below to your request:
{
"extendedProperties": {
"shared": {
"cases_1": null,
"cases_2": "2"
}
}
}
It was shown in this documentation:
Any properties not included in an update request will be deleted, but
a better approach is to make a patch request to set the value to null
Hope this helps.

Resources