upserting values in salesforce usin mule4 - salesforce

Am trying to upsert some values in salesforce object using mule4 transform my input is below
Transform shape:
%dw 2.0
output application/java
---
[{
Name: vars.det,
Request_Body__c: vars.Req
}]
The input payload am upserting is
input:
[{Name= MuleSoft--Salesforce, Request_Body__c= {
data = {
schema = PZAhU2AlqQtEHKOut4Rctg,
payload = {
Job_Prev_Name__c =Mule UWW, LastModifiedDate= 2020 - 09 - 15,
ChangeEventHeader = {
commitNumber = 1072316585812,
commitUser = 0057000001 cAAA,
sequenceNumber = 1,
entityName = ATI__c,
changeType = UPDATE,
changedFields =
}, Job_Name__c = Mule UWX, Name = CMule UWX}, event= {
replayId = 0311
}
},
channel = /data/ATI_Job__ChangeEvent
}
}]
While upserting am getting error like invalid input
How can i modify the "Request_Body__c" filed inorder to upsert in salesforce?

Related

Create Mock Custom Metadata with Child Relationship Query

I have a Controller class on which I execute a SOQL query to Custom Metadata Type records.
The SOQL query also contains a child relationship query (Master-Detail relationship).
I need to write a test with mock custom metadata records
#AuraEnabled(cacheable=true)
public static List<Response> getLeadMetadataValues() {
List<Lead_Business_Status__mdt> leadBusinessStatusList = [
SELECT Id, Label, DeveloperName, Index__c,
(SELECT Id, Label, DeveloperName, Reason_Status_Api_Name__c FROM Lead_Reason_Status__r)
FROM Lead_Business_Status__mdt ORDER BY Index__c ASC
];
List<Response> resList = new List<Response>();
if (Test.isRunningTest()) {
leadBusinessStatusList = new List<Lead_Business_Status__mdt>();
leadBusinessStatusList.add(createMock());
}
for (Lead_Business_Status__mdt bs : leadBusinessStatusList) {
Response res = new Response();
res.Id = bs.Id;
res.businessStatusLabel = bs.Label;
res.businessStatusDevName = bs.DeveloperName;
res.index = bs.Index__c;
for (Lead_Reason_Status__mdt rs : bs.Lead_Reason_Status__r) {
ReasonStatus rsObj = new ReasonStatus();
rsObj.Id = rs.Id;
rsObj.reasonStatusLabel = rs.Label;
rsObj.reasonStatusDevName = rs.DeveloperName;
rsObj.fieldApiName = rs.Reason_Status_Api_Name__c;
res.reasonStatusList.add(rsObj);
}
resList.add(res);
}
return resList;
}
I use Test.isRunningTest() to populate the leadBusinessStatusList with the mock data.
I am able to create a mock object for the Master record: Lead_Business_Status__mdt and Detail record: Lead_Reason_Status__mdt. However, I wasn't able to add the Detail record to the related list: Lead_Reason_Status__r
private static Lead_Business_Status__mdt createMock() {
String reasonStatusStr = '{"Label":"Transfer to Queue", "DeveloperName":"Transfer_to_Queue", "Reason_Status_Api_Name__c":"Transfer_to_Queue"}';
Lead_Reason_Status__mdt reasonStatusObj = (Lead_Reason_Status__mdt) System.JSON.deserialize(reasonStatusStr, Lead_Reason_Status__mdt.class);
System.debug('Lead_Reason_Status__mdt: ' + reasonStatusObj);
String businessStatusStr = '{"Label":"Wrong Lead", "DeveloperName":"Wrong_Lead", "Index__c":"1"}';
Lead_Business_Status__mdt businessStatusObj = (Lead_Business_Status__mdt) System.JSON.deserialize(businessStatusStr, Lead_Business_Status__mdt.class);
return businessStatusObj;
}
The test is covered except the inner for loop of the Lead_Reason_Status__mdt.
How can I create a mock object with populating the child relationship list?
Can you try use JSON.deserialize method to setup these metadata records.
List<Lead_Business_Status__mdt> leadBusinessStatusList = (List< Lead_Business_Status__mdt >) JSON.deserialize( '[{"Id": "xoid914011599", "Label": "test", "DeveloperName": "test","Reason_Status_Api_Name__c": "test"}, {"Id": "xoid9140115992","Label":"test2","DeveloperName": "test2","Reason_Status_Api_Name__c": "test2"}]', List<Lead_Business_Status__mdt>.class );

How to put an image overlay over video

I want to put an image overlay over video, but I'm not sure how I can do this. I'm trying to modify example from this repo Azure Media Services v3 .NET Core tutorials
, bascially what I changed here is transform:
private static Transform EnsureTransformForOverlayExists(IAzureMediaServicesClient client, string resourceGroupName, string accountName, string transformNameNew)
{
Console.WriteLine(transformNameNew);
Transform transform = client.Transforms.Get(resourceGroupName, accountName, transformName);
if (transform == null)
{
TransformOutput[] outputs = new TransformOutput[]
{
new TransformOutput(
new StandardEncoderPreset(
codecs: new Codec[]
{
new AacAudio(
channels: 2,
samplingRate: 48000,
bitrate: 128000,
profile: AacAudioProfile.AacLc
),
new H264Video(stretchMode: "AutoFit",
keyFrameInterval: TimeSpan.FromSeconds(2),
layers: new[]
{
new H264Layer(
bitrate: 1500000,
maxBitrate: 1500000,
width: "640",
height: "360"
)
}
),
new PngImage(
start: "25%",
step: "25%",
range: "80%",
layers: new PngLayer[]{
new PngLayer(
width: "50%",
height: "50%"
)
}
),
},
filters: new Filters
{
Overlays = new List<Overlay>
{
new VideoOverlay("input1")
}
},
formats: new Format[]
{
new Mp4Format(
filenamePattern: "{Basename}_letterbox{Extension}"
),
new PngFormat(
filenamePattern: "{Basename}_{Index}_{Label}_{Extension}"
),
}
))
};
transform = client.Transforms.CreateOrUpdate(resourceGroupName, accountName, transformName, outputs);
}
return transform;
}
and RunAsync method to provide multiple inputs where one of them should be an overlay:
private static async Task RunAsync(ConfigWrapper config)
{
IAzureMediaServicesClient client = await CreateMediaServicesClientAsync(config);
// Set the polling interval for long running operations to 2 seconds.
// The default value is 30 seconds for the .NET client SDK
client.LongRunningOperationRetryTimeout = 2;
try
{
// Ensure that you have customized encoding Transform. This is really a one time setup operation.
Transform overlayTransform = EnsureTransformForOverlayExists(client, config.ResourceGroup, config.AccountName, transformName);
// Creating a unique suffix so that we don't have name collisions if you run the sample
// multiple times without cleaning up.
string uniqueness = Guid.NewGuid().ToString().Substring(0, 13);
string jobName = "job-" + uniqueness;
string inputAssetName = "input-" + uniqueness;
string outputAssetName = "output-" + uniqueness;
Asset asset = client.Assets.CreateOrUpdate(config.ResourceGroup, config.AccountName, inputAssetName, new Asset());
var inputs = new JobInputs(new List<JobInput>());
var input = new JobInputHttp(
baseUri: "https://nimbuscdn-nimbuspm.streaming.mediaservices.windows.net/2b533311-b215-4409-80af-529c3e853622/",
files: new List<String> {"Ignite-short.mp4"},
label:"input1"
);
inputs.Inputs.Add((input));
input = new JobInputHttp(
baseUri: "SomeBaseUriHere",
files: new List<string> {"AssetVideo_000001_None_.png"},
label: "overlay");
inputs.Inputs.Add((input));
Asset outputAsset = CreateOutputAsset(client, config.ResourceGroup, config.AccountName, outputAssetName);
Job job = SubmitJob(client, config.ResourceGroup, config.AccountName, transformName, jobName, inputs, outputAsset.Name);
DateTime startedTime = DateTime.Now;
job = WaitForJobToFinish(client, config.ResourceGroup, config.AccountName, transformName, jobName);
TimeSpan elapsed = DateTime.Now - startedTime;
if (job.State == JobState.Finished)
{
Console.WriteLine("Job finished.");
if (!Directory.Exists(outputFolder))
Directory.CreateDirectory(outputFolder);
await MakeContainerPublic(client, config.ResourceGroup, config.AccountName, outputAsset.Name, config.BlobConnectionString);
DownloadResults(client, config.ResourceGroup, config.AccountName, outputAsset.Name, outputFolder).Wait();
}
else if (job.State == JobState.Error)
{
Console.WriteLine($"ERROR: Job finished with error message: {job.Outputs[0].Error.Message}");
Console.WriteLine($"ERROR: error details: {job.Outputs[0].Error.Details[0].Message}");
}
}
catch(ApiErrorException ex)
{
string code = ex.Body.Error.Code;
string message = ex.Body.Error.Message;
Console.WriteLine("ERROR:API call failed with error code: {0} and message: {1}", code, message);
}
}
But I have this error
Microsoft.Cloud.Media.Encoding.PresetException: Preset ERROR: There are 2 input assets. Preset has 2 Source but does NOT specify AssetID for each Source
and I have no idea how to overcome this.
At this time, it is not possible to use v3 APIs to create overlays. The feature is not fully implemented. See this link for other gaps between the v2 and v3 APIs.
For more details, you can see this site .

Snowflake : Load JSON with null values using empty string

I want to load empty strings in JSON as null value into snowflake table.
The snowflake document says that this should be possible with NULL_IF=('')
I tried that in COPY INTO statement, but did not work as expected.
Here is my sample JSON:
{
"Id": 100,
"Address": ""
}
Here is my sample query:
COPY INTO my_table FROM 's3://my_bucket/'
FILES = ('my_file.json')
FILE_FORMAT = (TYPE = json STRIP_OUTER_ARRAY = true NULL_IF = ('\\N', 'NULL', 'null', 'NUL', ''))
CREDENTIALS = (AWS_KEY_ID = 'my_key' AWS_SECRET_KEY = 'my_secret_key')
MATCH_BY_COLUMN_NAME = CASE_SENSITIVE
ON_ERROR = 'CONTINUE'
FORCE = TRUE ;

VS 2010 WPF Google API Calender V3 Insert Events

I have created a WPF Application in VS 2010 and user the Google API V3
I am facing the issue in
var CalEvt = mCalendarService.Events.Insert(new Event()
{
Description = item.Body.Substring(0, Math.Min(30, item.Body.Length)),
Start = new EventDateTime { DateTime = item.DueDateStart.ToString("o") },
End = new EventDateTime { DateTime = item.DueDateEnd.ToString("o") },
ETag = item.ExtractItemID.ToString(),
Reminders = new Event.RemindersData() { Overrides = l, UseDefault = false }
}, item.ExtractItemID.ToString()).Execute();
I am getting exception specified value is not in valid quoted string.
For Authentication I have used the below code
var auth = new OAuth2Authenticator(provider, GetAuthorization);
BaseClientService.Initializer initializer = new BaseClientService.Initializer();
initializer.Authenticator = auth;
mCalendarService = new Google.Apis.Calendar.v3.CalendarService(initializer);

Exchange Web Services Create Meeting Request Working Example

Is there a working example anywhere of how to create a meeting request using EWS for Exchange 2007 using C#? Which properties are required? I have added a web service reference and can connect to create and send various items but keep getting the error "Set action is invalid for property." on the response messages. It never says what property is invalid
var ews = new ExchangeServiceBinding {
Credentials = new NetworkCredential("user", "pass"),
Url = "https://servername/ews/exchange.asmx",
RequestServerVersionValue = new RequestServerVersion {
Version = ExchangeVersionType.Exchange2007}
};
var startDate = new DateTime(2010, 9, 18, 16, 00, 00);
var meeting = new CalendarItemType {
IsMeeting = true,
IsMeetingSpecified = true,
Subject = "test EWS",
Body = new BodyType {Value = "test body", BodyType1 = BodyTypeType.HTML},
Start = startDate,
StartSpecified = true,
End = startDate.AddHours(1),
EndSpecified = true,
MeetingTimeZone = new TimeZoneType{
TimeZoneName = TimeZone.CurrentTimeZone.StandardName, BaseOffset = "PT0H"},
Location = "Meeting",
RequiredAttendees = new [] {
new AttendeeType{Mailbox =new EmailAddressType{
EmailAddress ="test1#domain.com",RoutingType = "SMTP"}},
new AttendeeType{Mailbox =new EmailAddressType{
EmailAddress ="test2#domain.com",RoutingType = "SMTP"}}
}
};
var request = new CreateItemType {
SendMeetingInvitations =
CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy,
SendMeetingInvitationsSpecified = true,
SavedItemFolderId = new TargetFolderIdType{Item = new DistinguishedFolderIdType{
Id=DistinguishedFolderIdNameType.calendar}},
Items = new NonEmptyArrayOfAllItemsType {Items = new ItemType[] {meeting}}
};
CreateItemResponseType response = ews.CreateItem(request);
var responseMessage = response.ResponseMessages.Items[0];
Microsoft provides an XML example at http://msdn.microsoft.com/en-us/library/aa494190(EXCHG.140).aspx of what the message item should look like. Just setting these properties does not seem to be enough. Can someone tell me what I'm missing or point me to some better examples or documentation?
<CreateItem
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
SendMeetingInvitations="SendToAllAndSaveCopy" >
<SavedItemFolderId>
<t:DistinguishedFolderId Id="calendar"/>
</SavedItemFolderId>
<Items>
<t:CalendarItem>
<t:Subject>Meeting with attendee0, attendee1, attendee2</t:Subject>
<t:Body BodyType="Text">CalendarItem:TextBody</t:Body>
<t:Start>2006-06-25T10:00:00Z</t:Start>
<t:End>2006-06-25T11:00:00Z</t:End>
<t:Location>CalendarItem:Location</t:Location>
<t:RequiredAttendees>
<t:Attendee>
<t:Mailbox>
<t:EmailAddress>attendee0#example.com</t:EmailAddress>
</t:Mailbox>
</t:Attendee>
<t:Attendee>
<t:Mailbox>
<t:EmailAddress>attendee1#example.com</t:EmailAddress>
</t:Mailbox>
</t:Attendee>
</t:RequiredAttendees>
<t:OptionalAttendees>
<t:Attendee>
<t:Mailbox>
<t:EmailAddress>attendee2#example.com</t:EmailAddress>
</t:Mailbox>
</t:Attendee>
</t:OptionalAttendees>
<t:Resources>
<t:Attendee>
<t:Mailbox>
<t:EmailAddress>room0#example.com</t:EmailAddress>
</t:Mailbox>
</t:Attendee>
</t:Resources>
</t:CalendarItem>
</Items>
</CreateItem>
This is probably too late for you, but this for anyone else trying this.
The issue seems to be with providing the Is-Specified params. I deleted the IsMeetingSpecified and the request worked. Here's the revised CalendarItemType.
var meeting = new CalendarItemType
{
IsMeeting = true,
Subject = "test EWS",
Body = new BodyType { Value = "test body", BodyType1 = BodyTypeType.HTML },
Start = startDate,
StartSpecified = true,
End = startDate.AddHours(1),
EndSpecified = true,
MeetingTimeZone = new TimeZoneType
{
TimeZoneName = TimeZone.CurrentTimeZone.StandardName,
BaseOffset = "PT0H"
},
Location = "Room 1",
RequiredAttendees = new[] {
new AttendeeType
{
Mailbox =new EmailAddressType
{
EmailAddress ="test#test.com"
}
},
}
};

Resources