Directory users update clearing fields not included in resource - google-apps-script

Google's documentation states that Users.update will only update fields included in the userResource object. https://developers.google.com/admin-sdk/directory/v1/reference/users/update
In my script, I am able to submit updates successfully, but when I do, fields not specified are cleared out. Here's an example:
Original user resource:
{
orgUnitPath=/,
...
"organizations": [
{
"name": "John",
"title": "developer",
"primary": true,
"department": "IT",
"location": "CA",
"description": "fulltime_employee",
"domain": "acme.com",
"costCenter": "123456"
}]
}
I want to update just one of the fields, title = 'Sr. Developer'. When I submit the partial userResource with Users.update, the rest of the fields within the array element are cleared even though they were not submitted.
Submitted userResource
{
orgUnitPath=/,
...
"organizations": [
{
"title": "sr. developer"
}]
}
Updated user
{
orgUnitPath=/,
...
"organizations": [
{
"name": "",
"title": "sr. developer",
"primary": true,
"department": "",
"location": "",
"description": "",
"domain": "",
"costCenter": ""
}]
}
Is there a way to correct this, or do I need to load each field within the element and submit them all with only the changed fields updated?

Related

Dialogflow - Calling an intent on a button click

I have two buttons ('Category A' and 'Category B') created through custom payload in the 'Dialogflow Messenger' Integration. Once I click any category I want another intent to be triggered which would show the user few other buttons (sub-categories). I tried putting the welcome event name in the event section of the the code but that did not work for me (there were no changes at all). Could someone help me with this please?
I also do not know how to create new events. (I could not understand much from the 'events' documentation.) The style section does not work too. I want to change the layout of the buttons too. I do not have the knowledge of web-hook and fulfillment too.
"richContent": [
[
{
"icon": {
"color": "#FF9800",
"type": "chevron_right"
},
"event": {
"languageCode": "",
"name": "WELCOME",
"parameters": {}
},
"link": "https://google.com",
"text": "Career",
"type": "button",
"style": {
"background-color": "blue"
}
},
{
"type": "divider"
},
{
"icon": {
"type": "chevron_right",
"color": "#FF9800"
},
"link": "https://google.com",
"text": "Sales Inquiry",
"event": {
"languageCode": "",
"name": "",
"parameters": {}
},
"type": "button"
}
]
]
} ```
You need to enter language code as well.
"event": {
"languageCode": "en",
"name": "login-event",
"parameters": {}
}
I got this method worked for me.
Create intent and indicate matched event name on your button payload to event name created in intent.
"event": {
"name": "event_name_you_indicate",
},
In the same intent, provide action name.
Map your function once action name request received.
TLDR; You can check if this works out for you: https://medium.com/#varungoyal311213/dialogflow-rich-responses-click-event-438b984466ec

Getting an API generated in-person signing envelope tracked through Salesforce Connect

I'm using the rest API to create an in person signing session from salesforce. My envelope creation json is like this:
{
"documents": [{
"documentBase64": "'+base64EncodedDocToSign+'",
"documentId": "1",
"fileExtension": "pdf",
"name": "contract.pdf"
}
],
"emailSubject": "Please Sign",
"recipients": {
"inPersonSigners": [{
"email": "some#gsome.com",
"name": "Luis",
"hostEmail": "some#gsome.com",
"hostName": "Luis",
"signerEmail": "other#gother.com",
"signerName": "Charles",
"recipientId": "1",
"tabs": {
"signHereTabs": [{
"anchorString": "s1",
"anchorXOffset": "0",
"anchorYOffset": "0",
"anchorIgnoreIfNotPresent": "false",
"anchorUnits": "inches"
}
]
},
"routingOrder": "1",
"clientUserId": "1000",
"embeddedRecipientStartURL": "SIGN_AT_DOCUSIGN",
}
]
},
"status": "sent"
}
The next step would be for the object to be tracked using Connect. Connect is properly configured for the object and works if I "Sign with Docusign" or use a custom button.
I understand I must change the json to include the DSFSSourceObjectId custom field, with value equal to the Id of the object that is originating the request, but if I try to get a customField in there the json is not properly formatted anymore.
I tried adding the customField like:
...
}
]
},
"customFields": [
{
"Name": "DSFSSourceObjectId",
"Value": "' + objectId + '"
}
],
"status": "sent"
}
Is this viable?
I got this working adding the following to the JSON:
"customFields": {
"textCustomFields": [{
"value": "salesforceId",
"required": "false",
"show": "false",
"name": "DSFSSourceObjectId"
}
]
},

Optional DocuSign editor before sending

I am using the DocuSign API to generate digital agreements. So far all has gone well, but I now have a requirement to optionally have the contract sent to a user for editing within DocuSign before it is sent to the signatories.
My existing API calls are fairly simple, just using a template for the document:
POST https://demo.docusign.net/restapi/v2/accounts/<account_id>/envelopes HTTP/1.1
{
"status": "sent",
"templateId": "<template_id>",
"templateRoles": [
{
"email": "person1#company.com",
"name": "Person One",
"roleName": "Signatory1"
},
{
"email": "person2#somewhere.com",
"name": "Person Two",
"roleName": "Signatory2"
}
]
}
I need to have the same template sent to an editing user to adjust the envelope details before delivering to the signatories.
Anybody had any luck with a similar requirement?
Things I have tried:
Adding a compositeTemplates to the above request with an inline template that has an editor. This unfortunately removes all of the fields from the document.
Placing the whole request in compositeTemplates with the template selected as a server template, and the recipients in an inline template. This does not correctly match up the recipient roles to the template roles.
You can use the following composite template to add an Editor in addition to the template roles you have.
{
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "<template_id>"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "person1#company.com",
"name": "Person One",
"roleName": "Signatory1",
"recipientId": "1"
},
{
"email": "person2#company.com",
"name": "Person Two",
"roleName": "Signatory2",
"recipientId": "2"
}
],
"editors": [
{
"name": "person three",
"email": "personthree#company.com",
"recipientId": "3",
"routingOrder": "0"
}
]
}
}
]
}
]
}

Create DocuSign Envelope with Custom Fields

I am trying to add custom fields at the envelope level via the REST API and cannot get the values to be retained. The custom fields have been defined in the UI and come over in the envelope, but without the value that was assigned. If I add a custom field that was not defined in the UI, then it does not come over at all.
If I add the new custom field in a second call after the envelope is initially created, it will work, but that seems extraneous. What am I doing wrong?
Here is the JSON for creating a new custom field in the envelope:
{
"emailSubject": "Please Print, Complete and Sign Document",
"emailBlurb": "Please print and complete documents and sign on paper. ",
"status": "sent",
"customFields": {"textCustomFields":[{"name":"MyOwnField","required":"true","show":"true","value":"MyValue"}]},
"compositeTemplates": [{
"inlineTemplates": [{
"sequence": "1",
"recipients": {
"signers": [{
"requireSignOnPaper": "true",
"name":"Millard Fillmore",
"email":"dgilbert#firstallied.com",
"recipientId": "1",
"routingOrder": "1"
}]
}
}],
"document":
{
"documentId": "1",
"name": "Corestone Account Application.pdf",
"transformPdfFields": false
}
}]
}
The customFields object needs to be located inside the inlineTemplate object. Try this instead:
{
"emailSubject": "Please Print, Complete and Sign Document",
"emailBlurb": "Please print and complete documents and sign on paper. ",
"status": "sent",
"compositeTemplates": [{
"inlineTemplates": [{
"sequence": "1",
"customFields": {
"textCustomFields": [{
"name": "MyOwnField",
"required": "true",
"show": "true",
"value": "MyValue"
}]
},
"recipients": {
"signers": [{
"requireSignOnPaper": "true",
"name": "Millard Fillmore",
"email": "dgilbert#firstallied.com",
"recipientId": "1",
"routingOrder": "1"
}]
}
}],
"document": {
"documentId": "1",
"name": "Corestone Account Application.pdf",
"transformPdfFields": false
}
}]
}

Using custom json creating angular form and getting data

Hi I am using angular js to construct my application. I have one problem while generating dynamic form.
My json is :
{
lines :[ {
fields:[{
fieldType : "input",
labelName : "Test Label",
modelName : "testInput"
},{
fieldType : "select",
labelName : "Test Label",
options : "['opt1','opt2','opt3']",
modelName : "testSelect"
},{
fieldType : "checkbox",
labelName : "Test Label",
modelName : "testCheckbox",
options : '[{'key':'key1','value':'value1'}]"
}]
}
This is just sample json. In real time, it is more complex type. I am created separate component for all the Html Elements like "input","select","checkbox","radio"...
I am using Directives for all the input element. I am taking few details from parent scope of form to directive.
for eg:
Main Directive
<ui-form form-option='uiFormOption'></ui-form>
Above is the main directive. i am passing above json in this Main Directive.
Inside the directive, i am iterating all the lines and and calling respective directive to fill the components based on field type.
Here, in the Html component directives are creating isolated scope i need that too fine.
When i save this from, i need to get all the data in single object in ParentScope
something like
$scope.myFormData = {}; //Parent Scope controller.
when i click save, all the data must be collect. my problem is $scope in child directive. so model map not be aware to parent. How to achieve this...
I am not sure if I understood your question correctly, but two things popped in my mind, I am sure you tried them but just in case:
1- since you are able to get the data to the html components, bind the data directly to the object where you are collecting the data from, and since it is already accessible everywhere, you can just use it to format whatever response you need.
2- if no other option is available, you can use $scope.$root, I know it is not the best thing to do, but it is always the hack to get a shared scope for all your elements.
I hope this is what you are looking for, and in case it was not, please comment.
if you need to display dynamic form so fetch this kind of json object through API:
{
"status": "true",
"statusCode": 200,
"response": [
{
"sort_order": 0,
"control_name": "ion-select",
"label": "Select master OLT",
"type": "select",
"placeholder": "Select master OLT",
"name": "E0selectoption_master_olt",
"readonly": "True",
"required": "required",
"maxlength": "",
"minlength": ""
},
{
"sort_order": 1,
"control_name": "ion-select",
"label": "Select OLT port",
"type": "select",
"placeholder": "Select OLT port",
"name": "E1selectoption_olt_port",
"readonly": "True",
"required": "required",
"maxlength": "",
"minlength": ""
},
{
"sort_order": 2,
"control_name": "ion-select",
"label": "Select Parent node",
"type": "select",
"placeholder": "Select parent node",
"name": "E2selectoption_parent_node",
"readonly": "True",
"required": "required",
"maxlength": "",
"minlength": "",
"is_dependent": "true",
"masters": "gis_node",
"value": ""
},
{
"sort_order": 3,
"control_name": "ion-select",
"label": "Select child node",
"type": "select",
"placeholder": "Select child node",
"name": "E3selectoption_child_node",
"readonly": "True",
"required": "required",
"maxlength": "",
"minlength": "",
"is_dependent": "true",
"masters": "gis_node",
"value": ""
},
{
"sort_order": 4,
"control_name": "button",
"label": "submit",
"type": "submit",
"placeholder": "",
"name": "E4submit_btnsubmit",
"readonly": "False",
"required": "required",
"maxlength": "",
"minlength": "",
"is_dependent": "false",
"masters": "",
"value": ""
}
]
}
in the given response which is in JSON format.
so you can easily bind this data with our html