How to pay a specific invoice in netsuite? using customerPayment - postman

I am trying to pay a specific invoice using the customerpaymet endpoint, I made the JSON structure using the documentation from https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2021.1/index.html#/definitions/customerPayment-applyCollection
This is my JSON:
{
"aracct": {
"id": "259"
},
"autoApply": false,
"apply": {
"items": [
{
"amount": 12.06,
"apply": true,
"doc": {
"id": 5517
}
}
]
},
"tranDate": "2021-10-13 3:34:01 PM",
"customForm": {
"id": "70"
},
"customer": {
"id": "3645"
},
"payment": 12.06,
"subsidiary": {
"id": "3"
}
}
This is the error:
{
"detail": "Error while accessing a resource. You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.",
"o:errorPath": "apply",
"o:errorCode": "USER_ERROR"
}
I would appreciate any help!

This is how i do it in PHP, you can look at it for ideas on what you can try changing.
$request = [
'record_data' => [
[
'internalid' => $nsOrder['internalId'],
'source_type' => 'invoice',
'result_type' => 'customerpayment',
'transform_values' => '',
'literal_fields'=> [
'undepfunds' => 'F',
'account' => '123',
'customer' => $nsOrder['entity']['internalId'],
'paymentmethod' => '8',//cc
'memo' => $message,
],
'sublists'=> [
['name'=>'apply',
'update' => [
[
'match'=> 'internalid',
'data'=>[
'internalid'=>$nsOrder['internalId'],
'apply'=>'T',
'amount' => $nsOrder['amountRemaining']
]
]
]
]
]
]
]
];
$result = $this->curl->transform($request);

The answer is that you need to select a combination of Undep Funds | PaymentMethod and Account in order for this to succeed. The documentation for this exists here

Related

Boto3 create glue triggers with different types in one workflow

Can anyone please guide me steps to create multiple triggers types one with conditional and other with scheduled trigger type in single workflow
So far I have used create_trigger function . But above requirement not sure how to address.
Can any one help here please.
I have tried with below syntax didn't work
response = client.create_trigger(
Name='two_triggers',
WorkflowName='wf_With_two_tirggers',
Type='SCHEDULED',
Schedule='cron(0 12 * * ? *)',
Actions=[
{
'JobName': 'abc_dev',
'Arguments': {
'string': 'string'
},
'Timeout': 123,
'SecurityConfiguration': 'string',
'NotificationProperty': {
'NotifyDelayAfter': 123
},
'Trigger': 'string'
},
],
Type='CONDITIONAL',
Predicate={
'Logical': 'ANY',
'Conditions': [
{
'LogicalOperator': 'EQUALS',
'JobName': 'def_dev',
'State': 'SUCCEEDED'
},
]
},
Actions=[
{
'JobName': 'ghi_dev',
'Arguments': {
'string': 'string'
},
'Timeout': 123,
'SecurityConfiguration': 'string',
'NotificationProperty': {
'NotifyDelayAfter': 123
},
'CrawlerName': 'string'
},
],
Description='string',
StartOnCreation=True,
Tags={
'string': 'string'
}
)
Below is the design workflow struggling to write code for. Tried with above code for below design using boto3 didn't work
Yes I figured out on an answer. Below is the code for design given in question
import boto3
import os
import logging
glue = boto3.client(service_name="glue", region_name='us-east-1')
response = glue.create_workflow(
Name="dual_trigger_wf")
response1 = glue.create_trigger(
Name="trigger_one_to_many",
WorkflowName="dual_trigger_wf",
Type="SCHEDULED",
Schedule="cron(0 8 * * ? *)",
Actions=[
{
"JobName": "abc",
"Arguments": {"string": "string"},
"Timeout": 123,
"SecurityConfiguration": "string",
"NotificationProperty": {"NotifyDelayAfter": 123},
},
{
"JobName": "def",
"Arguments": {"string": "string"},
"Timeout": 123,
"SecurityConfiguration": "string",
"NotificationProperty": {"NotifyDelayAfter": 123},
},
],
Description="string",
StartOnCreation=False,
)
response2 = glue.create_trigger(
Name="trigger_many_to_one",
WorkflowName="dual_trigger_wf",
Type="CONDITIONAL",
Predicate={
"Logical": "AND",
"Conditions": [
{
"LogicalOperator": "EQUALS",
"JobName": "abc",
"State": "SUCCEEDED",
},
{
"LogicalOperator": "EQUALS",
"JobName": "def",
"State": "SUCCEEDED",
},
],
},
Actions=[
{
"JobName": "ghi",
"Arguments": {"string": "string"},
"Timeout": 123,
"SecurityConfiguration": "string",
"NotificationProperty": {"NotifyDelayAfter": 123},
}
],
Description="string",
StartOnCreation=False,
)

Unrecognized expression ‘$regex’

Not able to get desired output. Getting “Unrecognized expression ‘$regex’” error
[
{
'$lookup': {
'from': 'profiles',
'let': {
'userId': '$userId',
},
'pipeline': [
{
'$match': {
$expr: {
$and: [
{ '$eq': ['$uniqueId', '$$mcontactId'] },
{
$or: [{ 'birthDate': { '$regex': '$$today' } },
{ 'spouseBirthdate': { '$regex': '$$today' } },
{ 'weddingAnniversary': { '$regex': '$$today' } },
],
},
],
},
},
},
{
'$project': {
'userId': 1,
'uniqueId': 1,
'mobileNumber': 1,
'whatsApp': 1,
'emailId': 1,
'lastName': 1,
'firstName': 1,
'address': 1,
'signature': 1,
},
},
],
'as': 'profile',
},
},
]
$regex is a query operator, you are trying to use it within an $expr which uses the "aggregation" language as oppose to the "query" language normally used within a $match stage.
Apart from that you have some other issue's in your pipeline, for example you only define $userId as a variable for the $lookup stage but in it you're trying to use $$today and $$mcontactId which are not defined anywhere.
Regardless once you sort out those issue's you have two options:
if the regex match is not related to the input variables just use $regex outside the $expr, like so:
{
'$match': {
$and: [
{
$expr: {
'$eq': [
'$uniqueId',
'$$userId',
],
},
},
{
$or: [
{
'birthDate': {
'$regex': '03-05',
},
},
],
},
],
},
},
Mongo Playground
if the regex does not to use an input variable from the $lookup then you need to use an aggregation operator, like $regexMatch to do the match within the $expr

how to separate a list and map from map item in dart

I'm trying to separate a list from map item and also another map which is exist on my map item i'm beginner on dart?
someone help me how can do it?
Here is my list
var studentList2 = [
{
"Name": "Gias Uddin Samir",
"Id": "110",
"Result": [
{"Phy": "3.0", "Che": "4.0"}
],
"Completed": ["sp-2017", "sum-2017", "fall-2017"]
},
{
"Name": "Gias Uddin Samir",
"Id": "110",
"Result": [
{"Phy": "3.0", "Che": "4.0"}
],
"Completed": ["sp-2018", "sum-2018", "fall-2018"]
},
{
"Name": "Gias Uddin Samir",
"Id": "110",
"Result": [
{"Phy": "3.0", "Che": "4.0"}
],
"Completed": ["sp-2019", "sum-2019", "fall-2019"]
}
];
I want to separate Result list
"Result": [
{"Phy": "3.0", "Che": "4.0"}
],
ans also
"Completed": ["sp-2019", "sum-2019", "fall-2019"]
Maybe through the map method:
final results = studentList2.map((item) => item['Result']).toList();
print(results);
// [[{Phy: 3.0, Che: 4.0}], [{Phy: 3.0, Che: 4.0}], [{Phy: 3.0, Che: 4.0}]]
final completed = studentList2.map((item) => item['Completed']).toList();
print(completed);
// [[sp-2017, sum-2017, fall-2017], [sp-2018, sum-2018, fall-2018], [sp-2019, sum-2019, fall-2019]]

Facebook Marketing API Placement asset customization asset_feed_spec error

I'v been trying to automatically generate ads with different content based on the placements (facebook-feed, messenger-story). I'v been trying to follow the documentation.
https://developers.facebook.com/docs/marketing-api/dynamic-creative/placement-asset-customization#asset-feed
But for some reason, it returns an error saying that the entire object_story_spec is wrong. But this probably has to do something with my asset_feed_spec, because it's the only thing I have been changing.
object_story_spec param is invalid
Object story spec is ill formed. Maybe missing Page ID or creative details, or invalid fields exist
Have anyone tried to do this before? Or is there any way for me to get a clearer error message?
Here is the code I'm using when trying to create the creative.
$creative->setData([
AdCreativeFields::CALL_TO_ACTION_TYPE => $callToAction,
AdCreativeFields::IMAGE_HASH => $image_hash,
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
AdCreativeFields::ASSET_FEED_SPEC => $this->getAssetFeedSpec($post_message, $link_url, $headline, $image_hash, $description)
]);
To make it a bit more readable, I created a function that creates the different Asset feed specifications. To understand it a bit better, see the example in the documentation.
https://developers.facebook.com/docs/marketing-api/dynamic-creative/placement-asset-customization#supported-fields
public function getAssetFeedSpec($post_message, $link_url, $headline, $image_hash, $description) {
return [
'images' => [
[
'hash' => $image_hash
]
],
'bodies' => [
[
'adlabels' => [
[
'name' => 'labelfirst',
]
],
'text' => $post_message
],
[
'adlabels' => [
[
'name' => 'labelsecond',
]
],
'text' => $headline
]
],
'titles' => [
[
'text' => $headline
]
],
'descriptions' => [
[
'text' => $description
]
],
'ad_formats' => [
'SINGLE_IMAGE'
],
'call_to_action_types' => [
'LEARN_MORE'
],
'link_urls' => [
[
'website_url' => $link_url
]
],
'videos' => [],
'asset_customization_rules' => $this->getAssetCustomizationRules()
];
}
I also separated the asset_customization_rules to make that a bit more understandable.
public function getAssetCustomizationRules() {
return [
[
'customization_spec' => [
'publisher_platforms' => [
'facebook',
'instagram',
'audience_network',
'messenger'
],
'facebook_positions' => [
'feed',
],
'instagram_positions' => [
'stream'
],
'audience_network_positions' => [
'classic'
]
],
'body_label' => [
'name' => 'labelfirst'
]
],
[
'customization_spec' => [
'publisher_platforms' => [
'messenger'
],
'messenger_positions' => [
'stream'
]
],
'body_label' => [
'name' => 'labelsecond'
]
]
];
}
To generate creative, you need to pass object_story_spec with valid page_id just like below,
{
"object_story_spec": {
"page_id": "10506210208xxx"
},
"asset_feed_spec": {
"videos": [
{
"adlabels": [
{
"name": "placement_asset_3667064314xxx"
}
],
"video_id": "3667064314xxx"
},
..
It should work after providing a valid page_id, It's working for me.

Get related data through relation

I am using laravel 5.5.13.
I have App\Entity which has many App\Comment's and many App\Thumb's.
Now I am able to fetch the Comments and Thumbs easily like this:
public function show(Entity $entity)
{
return $entity->load('comments')->load('thumbs');
}
This gives data like this:
{
"id": 1,
"kind": null,
"name": "three",
"created_at": "2017-11-01 04:29:22",
"updated_at": "2017-11-01 04:29:22",
"comments": [
{
"id": 5,
"body": "no non o",
"displayname_id": 4,
"entity_id": 1,
"created_at": "2017-11-01 05:16:14",
"updated_at": "2017-11-01 05:16:14"
}
],
"thumbs": [
{
"id": 9,
"like": 0,
"displayname_id": 5,
"entity_id": 1,
"created_at": "2017-11-01 05:16:39",
"updated_at": "2017-11-01 05:16:39"
}
]
}
However, I also need a list of the $comment->displaynames() and $thumb->displaynames() and also each comment has many App\Votes via the $comment->votes(). Is it possible. I read lots on pivot but I am real confused.
My goal is to get data like this:
{
// removed for concise (same as above)
"comments": [
{
// removed for concise (same as above)
"votes": [
..... // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< I want to get this
]
},
{
// removed for concise (same as above)
"votes": [
..... // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< I want to get this
]
}
],
"thumbs": [
{
// removed for concise (same as above)
}
],
"displaynames": [
..... // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< I want to get this
]
}
We see here the new displaynames array and a votes array in each comment.
Do i have to use pivot here to in a one-to-many relationship?
Your controller:
Entity::
with(['comments' => function($query){
$query->with('votes');
}, 'thumbs' => function($query){
$query->with('votes');
}])
->find($entity->id);
And relations:
entity has many comments
entity has many thumbs
thumb has many votes
comment has many votes
And you should tell more specific information about displayName relation...
EDIT:
Entity::
with(['comments' => function($query){
$query->with(['votes', 'displayName']);
}, 'thumbs' => function($query){
$query->with(['votes', 'displayName']);
}, 'displayName'])
->find($entity->id);
EDIT-2:
Entity::
with(['comments' => function($query){
$query->with(['votes' => function($query){
$query->with('displayName');
}, 'displayName']);
}, 'thumbs' => function($query){
$query->with(['votes' => function($query){
$query->with('displayName');
}, 'displayName']);
}, 'displayName'])
->find($entity->id);